Packagecom.yworks.bridge.util
Classpublic class LinkedList
InheritanceLinkedList Inheritance AbstractSequentialList Inheritance AbstractList Inheritance AbstractCollection Inheritance YObject Inheritance Object
Implements List, Clonable

LinkedList is an implementation of List, backed by a linked list. All optional operations are supported, adding, removing and replacing. The elements can be any objects.



Public Properties
 PropertyDefined By
 Inheritedempty : Boolean
[read-only] Returns true if the collection has no element, otherwise false.
AbstractCollection
  first : Object
[read-only] Answers the first element in this LinkedList.
LinkedList
  last : Object
[read-only] Answers the last element in this LinkedList.
LinkedList
  length : int
[override] [read-only] Answers the number of elements in this LinkedList.
LinkedList
 InheritedmodCountInternal : int
AbstractList
Protected Properties
 PropertyDefined By
 InheritedmodCount : int
AbstractList
Public Methods
 MethodDefined By
  
LinkedList(init:Boolean = true)
Constructs a new empty instance of LinkedList.
LinkedList
  
addAll(collection:Collection):Boolean
[override] Adds the objects in the specified Collection to this LinkedList.
LinkedList
  
addAllAt(location:int, collection:Collection):Boolean
[override] Inserts the objects in the specified Collection at the specified location in this LinkedList.
LinkedList
  
addFirst(object:Object):void
Adds the specified object at the beginning of this LinkedList.
LinkedList
  
addItem(object:Object):Boolean
[override] Adds the specified object at the end of this LinkedList.
LinkedList
  
addItemAt(location:int, object:Object):void
[override] Inserts the specified object into this LinkedList at the specified location.
LinkedList
  
addLast(object:Object):void
Adds the specified object at the end of this LinkedList.
LinkedList
  
clear():void
[override] Removes all elements from this LinkedList, leaving it empty.
LinkedList
  
clone():Object
[override] Answers a new LinkedList with the same elements and size as this LinkedList.
LinkedList
 Inherited
containsAll(collection:Collection):Boolean
Searches this Collection for all objects in the specified Collection.
AbstractCollection
  
containsItem(object:Object):Boolean
[override] Searches this LinkedList for the specified object.
LinkedList
  
element():Object
LinkedList
 Inherited
equals(object:Object):Boolean
[override] Compares the specified object to this List and answer if they are equal.
AbstractList
  
getClass():Class
[override]
LinkedList
  
getItemAt(location:int):Object
[override]
LinkedList
 Inherited
hashCode():int
[override] Answers an integer hash code for the receiver.
AbstractList
  
indexOf(object:Object):int
[override] Searches this LinkedList for the specified object and returns the index of the first occurrence.
LinkedList
 Inherited
[override] Answers an Iterator on the elements of this List.
AbstractSequentialList
  
lastIndexOf(object:Object):int
[override] Searches this LinkedList for the specified object and returns the index of the last occurrence.
LinkedList
 Inherited
Answers a ListIterator on the elements of this List.
AbstractList
  
[override] Answers a ListIterator on the elements of this LinkedList.
LinkedList
  
[static] Constructs a new empty instance of LinkedList.
LinkedList
  
[static] Constructs a new instance of LinkedList that holds all of the elements contained in the supplied collection argument.
LinkedList
  
offer(o:Object):Boolean
LinkedList
  
peek():Object
LinkedList
  
poll():Object
LinkedList
 Inherited
removeAll(collection:Collection):Boolean
Removes all occurrences in this Collection of each object in the specified Collection.
AbstractCollection
  
removeFirst():Object
Removes the first object from this LinkedList.
LinkedList
  
removeItem(object:Object):Boolean
[override]
LinkedList
  
removeItemAt(location:int):Object
[override] Removes the object at the specified location from this LinkedList.
LinkedList
  
removeLast():Object
Removes the last object from this LinkedList.
LinkedList
 Inherited
retainAll(collection:Collection):Boolean
Removes all objects from this Collection that are not contained in the specified Collection.
AbstractCollection
  
setItemAt(location:int, object:Object):Object
[override] Replaces the element at the specified location in this LinkedList with the specified object.
LinkedList
 Inherited
subList(start:int, end:int):List
Returns a part of consecutive elements of this list as a view.
AbstractList
  
toArray():Vector.<Object>
[override] Answers a new array containing all elements contained in this LinkedList.
LinkedList
  
toArray2(contents:Vector.<Object>):Vector.<Object>
[override] Answers an array containing all elements contained in this LinkedList.
LinkedList
 Inherited
toString():String
Answers the string representation of this Collection.
AbstractCollection
Protected Methods
 MethodDefined By
  
cloneImpl(o:Object):void
[override]
LinkedList
 Inherited
AbstractCollection
 Inherited
AbstractList
 Inherited
AbstractSequentialList
  
Initializes this object.
LinkedList
  
initLinkedList2(collection:Collection):void
Initializes this object.
LinkedList
 Inherited
removeRange(start:int, end:int):void
Removes the objects in the specified range from the start to the, but not including, end index.
AbstractList
Property Detail
firstproperty
first:Object  [read-only]

Answers the first element in this LinkedList.


Implementation
    public function get first():Object

Throws
Error — when this LinkedList is empty
lastproperty 
last:Object  [read-only]

Answers the last element in this LinkedList.


Implementation
    public function get last():Object

Throws
Error — when this LinkedList is empty
lengthproperty 
length:int  [read-only] [override]

Answers the number of elements in this LinkedList.


Implementation
    public function get length():int
Constructor Detail
LinkedList()Constructor
public function LinkedList(init:Boolean = true)

Constructs a new empty instance of LinkedList.

Parameters
init:Boolean (default = true) — An internally used switch to help handle proper instance initialization in inheritance chains where classes can have multiple constructor-like factory methods. This parameter can safely be ignored/omitted when calling the constructor.
Method Detail
addAll()method
override public function addAll(collection:Collection):Boolean

Adds the objects in the specified Collection to this LinkedList.

Parameters

collection:Collection — the Collection of objects

Returns
Boolean — true if this LinkedList is modified, false otherwise
addAllAt()method 
override public function addAllAt(location:int, collection:Collection):Boolean

Inserts the objects in the specified Collection at the specified location in this LinkedList. The objects are added in the order they are returned from the Collection iterator.

Parameters

location:int — the index at which to insert
 
collection:Collection — the Collection of objects

Returns
Boolean — true if this LinkedList is modified, false otherwise

Throws
RangeError — when location < 0 || > size()
addFirst()method 
public function addFirst(object:Object):void

Adds the specified object at the beginning of this LinkedList.

Parameters

object:Object — the object to add

addItem()method 
override public function addItem(object:Object):Boolean

Adds the specified object at the end of this LinkedList.

Parameters

object:Object — the object to add

Returns
Boolean — true
addItemAt()method 
override public function addItemAt(location:int, object:Object):void

Inserts the specified object into this LinkedList at the specified location. The object is inserted before any previous element at the specified location. If the location is equal to the size of this LinkedList, the object is added at the end.

Parameters

location:int — the index at which to insert
 
object:Object — the object to add


Throws
RangeError — when location < 0 || >= size()
addLast()method 
public function addLast(object:Object):void

Adds the specified object at the end of this LinkedList.

Parameters

object:Object — the object to add

clear()method 
override public function clear():void

Removes all elements from this LinkedList, leaving it empty.

See also

clone()method 
override public function clone():Object

Answers a new LinkedList with the same elements and size as this LinkedList.

Returns
Object — a shallow copy of this LinkedList

See also

cloneImpl()method 
override protected function cloneImpl(o:Object):void

Parameters

o:Object

containsItem()method 
override public function containsItem(object:Object):Boolean

Searches this LinkedList for the specified object.

Parameters

object:Object — the object to search for

Returns
Boolean — true if object is an element of this LinkedList, false otherwise
element()method 
public function element():Object

Returns
Object
getClass()method 
override public function getClass():Class

Returns
Class
getItemAt()method 
override public function getItemAt(location:int):Object

Parameters

location:int

Returns
Object
indexOf()method 
override public function indexOf(object:Object):int

Searches this LinkedList for the specified object and returns the index of the first occurrence.

Parameters

object:Object — the object to search for

Returns
int — the index of the first occurrence of the object
initLinkedList1()method 
protected final function initLinkedList1():void

Initializes this object. See the documentation of the corresponding factory method newLinkedList1() for details.

See also

initLinkedList2()method 
protected final function initLinkedList2(collection:Collection):void

Initializes this object. See the documentation of the corresponding factory method newLinkedList2() for details.

Parameters

collection:Collection

See also

lastIndexOf()method 
override public function lastIndexOf(object:Object):int

Searches this LinkedList for the specified object and returns the index of the last occurrence.

Parameters

object:Object — the object to search for

Returns
int — the index of the last occurrence of the object
listIterator2()method 
override public function listIterator2(location:int):ListIterator

Answers a ListIterator on the elements of this LinkedList. The elements are iterated in the same order that they occur in the LinkedList. The iteration starts at the specified location.

Parameters

location:int — the index at which to start the iteration

Returns
ListIterator — a ListIterator on the elements of this LinkedList

Throws
RangeError — when location < 0 || >= size()

See also

newLinkedList1()method 
public static function newLinkedList1():LinkedList

Constructs a new empty instance of LinkedList.

Returns
LinkedList
newLinkedList2()method 
public static function newLinkedList2(collection:Collection):LinkedList

Constructs a new instance of LinkedList that holds all of the elements contained in the supplied collection argument. The order of the elements in this new LinkedList will be determined by the iteration order of collection.

Parameters

collection:Collection — the collection of elements to add

Returns
LinkedList
offer()method 
public function offer(o:Object):Boolean

Parameters

o:Object

Returns
Boolean
peek()method 
public function peek():Object

Returns
Object
poll()method 
public function poll():Object

Returns
Object
removeFirst()method 
public function removeFirst():Object

Removes the first object from this LinkedList.

Returns
Object — the removed object

Throws
Error — when this LinkedList is empty
removeItem()method 
override public function removeItem(object:Object):Boolean

Parameters

object:Object

Returns
Boolean
removeItemAt()method 
override public function removeItemAt(location:int):Object

Removes the object at the specified location from this LinkedList.

Parameters

location:int — the index of the object to remove

Returns
Object — the removed object

Throws
RangeError — when location < 0 || >= size()
removeLast()method 
public function removeLast():Object

Removes the last object from this LinkedList.

Returns
Object — the removed object

Throws
Error — when this LinkedList is empty
setItemAt()method 
override public function setItemAt(location:int, object:Object):Object

Replaces the element at the specified location in this LinkedList with the specified object.

Parameters

location:int — the index at which to put the specified object
 
object:Object — the object to add

Returns
Object — the previous element at the index

Throws
RangeError — when location < 0 || >= size()
toArray()method 
override public function toArray():Vector.<Object>

Answers a new array containing all elements contained in this LinkedList.

Returns
Vector.<Object> — an array of the elements from this LinkedList
toArray2()method 
override public function toArray2(contents:Vector.<Object>):Vector.<Object>

Answers an array containing all elements contained in this LinkedList. If the specified array is large enough to hold the elements, the specified array is used, otherwise an array of the same type is created. If the specified array is used and is larger than this LinkedList, the array element following the collection elements is set to null.

Parameters

contents:Vector.<Object> — the array

Returns
Vector.<Object> — an array of the elements from this LinkedList

Throws
Error — when the type of an element in this LinkedList cannot be stored in the type of the specified array