List and SortedList

Here are two sorts of lined lists. They are easy to use and not very hard to understand. You can simply insert() something into a list and walk() through it. If the list is an instance of SortedList it will be sorted automatically.

[as]import de.je2050.util.SortedList;
import de.je2050.util.List;
import de.je2050.util.data.*;

var simple: List = new List();
var sorted: SortedList = new SortedList();

for ( var i: Number = 0; i < 10; i++)
{
var n: Number = random( 100 );
simple.insert( new NumberData( n ) );
sorted.insert( new NumberData( n ) );
}

trace( 'unsorted' );
simple.walk( trace );

trace( 'sorted' );
sorted.walk( trace );[/as]

Post a Comment

Your email is never shared. Required fields are marked *

*
*