Added some methods to StreamableArrayList that behave properly (use Equalable
to determine equality instead of using reference equality). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4407 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -9,6 +9,48 @@ import com.threerings.io.Streamable;
|
|||||||
public class StreamableArrayList extends ArrayCollection
|
public class StreamableArrayList extends ArrayCollection
|
||||||
implements Streamable
|
implements Streamable
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Returns the index of the specified object in this collection, using
|
||||||
|
* Equalable.equals() if possible.
|
||||||
|
*/
|
||||||
|
public function indexOf (object :Object) :int
|
||||||
|
{
|
||||||
|
return ArrayUtil.indexOf(source, object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the first instance of the supplied object from this array, using
|
||||||
|
* Equalable.equals() to determine equality. Returns the removed object if
|
||||||
|
* a match was found, null otherwise.
|
||||||
|
*/
|
||||||
|
public function remove (object :Object) :Object
|
||||||
|
{
|
||||||
|
return ArrayUtil.removeFirst(source, object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds all of the elements of the supplied collection to the end of this
|
||||||
|
* list.
|
||||||
|
*/
|
||||||
|
public function addAll (list :ArrayCollection) :void
|
||||||
|
{
|
||||||
|
for (var ii :int = 0; ii < list.length; ii++) {
|
||||||
|
addItem(list.getItemAt(ii));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts and returns a sublist from this list.
|
||||||
|
*/
|
||||||
|
public function subList (startIdx :int, endIdx :int) :ArrayCollection
|
||||||
|
{
|
||||||
|
var newlist :ArrayCollection = new ArrayCollection();
|
||||||
|
for (var ii :int = startIdx; ii <= endIdx; ii++) {
|
||||||
|
newlist.addItem(getItemAt(ii));
|
||||||
|
}
|
||||||
|
return newlist;
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited from interface Streamable
|
// documentation inherited from interface Streamable
|
||||||
public function writeObject (out :ObjectOutputStream) :void
|
public function writeObject (out :ObjectOutputStream) :void
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user