| Package | system.data.lists |
| Class | public class LinkedList |
| Inheritance | LinkedList Object |
| Implements | Equatable, List, Queue |
Implements all optional list operations, and permits all elements (including null).
In addition to implementing the List interface, the LinkedList class provides uniformly named methods to get, remove and insert an element at the beginning and end of the list.
These operations allow linked lists to be used as a stack, queue, etc.
| Property | Defined By | ||
|---|---|---|---|
| modCount : int
This property is a protector used in the ListIterator object of this List. | LinkedList | ||
| Method | Defined By | ||
|---|---|---|---|
LinkedList(init:* = null)
Creates a new LinkedList instance. | LinkedList | ||
add(o:*):Boolean
Appends the specified element to the end of this list. | LinkedList | ||
addAll(c:Collection):Boolean
Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator. | LinkedList | ||
addAllAt(index:uint, c:Collection):Boolean
Inserts all of the elements in the specified collection into this list at the specified position (optional operation). | LinkedList | ||
addAt(index:uint, o:*):void
Inserts the specified element at the specified position in this list (optional operation). | LinkedList | ||
addFirst(o:*):void
Inserts the given element at the beginning of this list. | LinkedList | ||
addLast(o:*):void
Appends the given element to the end of this list. | LinkedList | ||
clear():void
Removes all of the elements from this queue (optional operation). | LinkedList | ||
clone():*
Returns the shallow copy of this LinkedList. | LinkedList | ||
contains(o:*):Boolean
Returns true if this list contains the specified element. | LinkedList | ||
containsAll(c:Collection):Boolean
Returns true if this collection contains the specified element. | LinkedList | ||
dequeue():Boolean
Retrieves and removes the head of this queue. | LinkedList | ||
element():*
Retrieves, but does not remove, the head (first element) of this list. | LinkedList | ||
enqueue(o:*):Boolean
Adds the specified element as the tail (last element) of this list. | LinkedList | ||
equals(o:*):Boolean
Indicates whether some other object is "equal to" this one. | LinkedList | ||
get(key:*):*
Returns the element at the specified position in this list. | LinkedList | ||
getFirst():*
Returns the first element in this list. | LinkedList | ||
Returns the header entry of this list. | LinkedList | ||
getLast():*
Returns the last element in the list. | LinkedList | ||
indexOf(o:*, fromIndex:uint = 0):int
Returns the position of the passed object in the collection. | LinkedList | ||
isEmpty():Boolean
Returns true if this queue contains no elements. | LinkedList | ||
Returns the iterator of this object. | LinkedList | ||
lastIndexOf(o:*, fromIndex:int = 0x7FFFFFFF):int
Returns the index in this list of the last occurrence of the specified element, or -1 if the list does not contain this element. | LinkedList | ||
listIterator(position:uint = 0):ListIterator
Returns a list iterator of the elements in this list (in proper sequence). | LinkedList | ||
peek():*
Retrieves, but does not remove, the head (first element) of this list. | LinkedList | ||
poll():*
Retrieves and removes the head (first element) of this list. | LinkedList | ||
remove(o:*):*
Removes the first occurrence of the specified element in this list. | LinkedList | ||
removeAll(c:Collection):Boolean
Removes all elements defined in the specified Collection in the list. | LinkedList | ||
removeAt(index:uint, len:int = 1):*
Removes an element at the specified position in this list. | LinkedList | ||
Removes an Entry in the list. | LinkedList | ||
removeFirst():*
Removes and returns the first element from this list. | LinkedList | ||
removeLast():*
Removes and returns the last element from this list. | LinkedList | ||
removeRange(fromIndex:uint, toIndex:uint):*
Removes from this list all the elements that are contained between the specific from and the specific to position in this list (optional operation). | LinkedList | ||
retainAll(c:Collection):Boolean
Retains only the elements in this list that are contained in the specified collection (optional operation). | LinkedList | ||
set(index:uint, o:*):*
Replaces the element at the specified position in this list with the specified element. | LinkedList | ||
size():uint
Returns the number of elements in this list. | LinkedList | ||
Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. | LinkedList | ||
toArray():Array
Returns an array containing all of the elements in this list in the correct order. | LinkedList | ||
toSource(indent:int = 0):String
Returns the source code string representation of the object. | LinkedList | ||
toString():String
Returns the string representation of this instance. | LinkedList | ||
| modCount | property |
modCount:intThis property is a protector used in the ListIterator object of this List.
public function get modCount():int public function set modCount(value:int):void| LinkedList | () | Constructor |
public function LinkedList(init:* = null)Creates a new LinkedList instance.
Usage :
var list:LinkedList = new LinkedList() ;
Parameters init:* (default = null) — An optional Array or Collection or Iterable object to fill the collection.
|
| add | () | method |
public function add(o:*):BooleanAppends the specified element to the end of this list.
Parameters
o:* — element to be appended to this list.
|
Boolean — true (as per the general contract of Collection.add).
|
| addAll | () | method |
public function addAll(c:Collection):BooleanAppends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified Collection is this list, and this list is nonempty.)
Parameters
c:Collection — the elements to be inserted into this list.
|
Boolean — true if this list changed as a result of the call.
|
NullPointerException — if the specified collection is null.
|
| addAllAt | () | method |
public function addAllAt(index:uint, c:Collection):BooleanInserts all of the elements in the specified collection into this list at the specified position (optional operation).
Parameters
index:uint — the index to insert the new elements from the specified Collection.
| |
c:Collection — the collection of elements to insert in the List.
|
Boolean |
| addAt | () | method |
public function addAt(index:uint, o:*):voidInserts the specified element at the specified position in this list (optional operation).
Parameters
index:uint — index at which the specified element is to be inserted.
| |
o:* — element to be inserted.
|
| addFirst | () | method |
public function addFirst(o:*):voidInserts the given element at the beginning of this list.
Parameters
o:* — the element to be inserted at the beginning of this list.
|
| addLast | () | method |
public function addLast(o:*):voidAppends the given element to the end of this list.
Parameters
o:* — the element to be inserted at the end of this list.
|
| clear | () | method |
public function clear():voidRemoves all of the elements from this queue (optional operation).
| clone | () | method |
public function clone():*Returns the shallow copy of this LinkedList.
Returns* — the shallow copy of this LinkedList.
|
| contains | () | method |
public function contains(o:*):Boolean
Returns true if this list contains the specified element.
Example :
import system.data.lists.LinkedList ;
var list:LinkedList = new LinkedList() ;
list.add("item1") ;
trace(list.contains( "item1" ) ; // output : true
Parameters
o:* — element whose presence in this list is to be tested.
|
Boolean — true if this list contains the specified element.
|
| containsAll | () | method |
public function containsAll(c:Collection):Boolean
Returns true if this collection contains the specified element.
Parameters
c:Collection |
Boolean — true if this collection contains the specified element.
|
| dequeue | () | method |
public function dequeue():BooleanRetrieves and removes the head of this queue.
ReturnsBoolean — true if the head of the queue is remove.
|
| element | () | method |
public function element():*Retrieves, but does not remove, the head (first element) of this list.
Returns* — the head of this queue.
|
NoSuchElementException — if this queue is empty.
|
| enqueue | () | method |
public function enqueue(o:*):BooleanAdds the specified element as the tail (last element) of this list.
Parameters
o:* — the element to add.
|
Boolean — true if the element in inserted in the list.
|
| equals | () | method |
public function equals(o:*):BooleanIndicates whether some other object is "equal to" this one.
Parameters
o:* |
Boolean |
| get | () | method |
public function get(key:*):*Returns the element at the specified position in this list.
Parameters
key:* — index of element to return.
|
* — the element at the specified position in this list.
|
NoSuchElementError — No value exist at the specified index.
|
| getFirst | () | method |
public function getFirst():*Returns the first element in this list.
Returns* — the first element in this list.
|
NoSuchElementException — if this list is empty.
|
| getHeader | () | method |
public function getHeader():LinkedListEntryReturns the header entry of this list.
ReturnsLinkedListEntry — the header entry of this list.
|
| getLast | () | method |
public function getLast():*Returns the last element in the list.
Returns* — the last element in the list.
|
NoSuchElementException — if this list is empty.
|
| indexOf | () | method |
public function indexOf(o:*, fromIndex:uint = 0):intReturns the position of the passed object in the collection.
Parameters
o:* — the object to search in the collection.
| |
fromIndex:uint (default = 0) — the index to begin the search in the collection.
|
int — the index of the object or -1 if the object isn't find in the collection.
|
| isEmpty | () | method |
public function isEmpty():Boolean
Returns true if this queue contains no elements.
Boolean — true if this queue is empty else false.
|
| iterator | () | method |
public function iterator():IteratorReturns the iterator of this object.
ReturnsIterator — the iterator of this object.
|
| lastIndexOf | () | method |
public function lastIndexOf(o:*, fromIndex:int = 0x7FFFFFFF):intReturns the index in this list of the last occurrence of the specified element, or -1 if the list does not contain this element.
Parameters
o:* — element to search for.
| |
fromIndex:int (default = 0x7FFFFFFF) |
int — the index in this list of the last occurrence of the specified element, or -1 if the list does not contain this element.
|
| listIterator | () | method |
public function listIterator(position:uint = 0):ListIteratorReturns a list iterator of the elements in this list (in proper sequence).
Parameters
position:uint (default = 0) |
ListIterator — a list iterator of the elements in this list (in proper sequence).
|
| peek | () | method |
public function peek():*Retrieves, but does not remove, the head (first element) of this list.
Returns* — the head of this queue, or null if this queue is empty.
|
| poll | () | method |
public function poll():*Retrieves and removes the head (first element) of this list.
Returns* — the head of this queue, or null if this queue is empty.
|
| remove | () | method |
public function remove(o:*):*Removes the first occurrence of the specified element in this list. If the list does not contain the element, it is unchanged.
Parameters
o:* — element to be removed from this list, if present.
|
* — if the list contained the specified element.
|
| removeAll | () | method |
public function removeAll(c:Collection):BooleanRemoves all elements defined in the specified Collection in the list.
Example :
import system.data.collections.ArrayCollection ;
import system.data.lists.LinkedList ;
var list:LinkedList = new LinkedList() ;
list.add("item1") ;
list.add("item2") ;
trace(list.removeAll(new ArrayCollection(["item1"])) ; // true
trace(list) ; // {item2}
Parameters
c:Collection |
Boolean — true if all elements are find and remove in the list.
|
| removeAt | () | method |
public function removeAt(index:uint, len:int = 1):*
Removes an element at the specified position in this list.
This implementation first gets a list iterator pointing to the indexed element (with listIterator(index)).
Then, it removes the element with ListIterator remove method.
Example :
import system.data.lists.LinkedList ;
var list:LinkedList = new LinkedList() ;
list.add("item1") ;
list.add("item2") ;
trace(list.removeAt(1)) ; // item2
trace(list) ; // {item1}
Parameters
index:uint — index of the element to be removed from the List.
| |
len:int (default = 1) |
* — the Array representation of all removed elements in the list.
|
| removeEntry | () | method |
public function removeEntry(e:LinkedListEntry):*Removes an Entry in the list.
Parameters
e:LinkedListEntry |
* |
| removeFirst | () | method |
public function removeFirst():*Removes and returns the first element from this list.
Example :
import system.data.lists.LinkedList ;
var list:LinkedList = new LinkedList() ;
list.add("item1") ;
list.add("item2") ;
list.add("item3") ;
list.add("item4") ;
var result = list.removeFirst() ;
trace(result + " : " + list) ; // item1 : {item2,item3,item4}
Returns* — the first element from this list.
|
NoSuchElementException — if this list is empty.
|
| removeLast | () | method |
public function removeLast():*Removes and returns the last element from this list.
Example :
import systel.data.lists.LinkedList ;
var list:LinkedList = new LinkedList() ;
list.add("item1") ;
list.add("item2") ;
list.add("item3") ;
list.add("item4") ;
var result = list.removeLast() ;
trace(result + " : " + list) ; // item4 : {item1,item2,item3}
Returns* — the last element from this list.
|
NoSuchElementException — if this list is empty.
|
| removeRange | () | method |
public function removeRange(fromIndex:uint, toIndex:uint):*
Removes from this list all the elements that are contained between the specific from and the specific to position in this list (optional operation).
Example :
import system.data.lists.LinkedList ;
var list:LinkedList = new LinkedList() ;
list.add("item1") ;
list.add("item2") ;
list.add("item3") ;
list.add("item4") ;
list.add("item5") ;
list.removeRange(2, 4) ;
trace(list) ; // {item1,item2,item5}
Parameters
fromIndex:uint | |
toIndex:uint |
* |
RangeError — if the 'toIndex' value > 'fromIndex' value.
|
| retainAll | () | method |
public function retainAll(c:Collection):BooleanRetains only the elements in this list that are contained in the specified collection (optional operation).
Example :
import system.data.collections.ArrayCollection ;
import system.data.lists.LinkedList ;
var list:LinkedList = new LinkedList() ;
list.add("item1") ;
list.add("item2") ;
list.add("item3") ;
list.add("item4") ;
list.add("item5") ;
var c:ArrayCollection = new ArrayCollection( ["item2", "item4"] ) ;
var b:Boolean = list.retainAll( c ) ;
trace("list : " + list + ", is retain ? : " + b) ;
Parameters
c:Collection |
Boolean — true if the retainAll operation is success.
|
| set | () | method |
public function set(index:uint, o:*):*Replaces the element at the specified position in this list with the specified element.
Example :
import system.data.lists.LinkedList ;
var list:LinkedList = new LinkedList() ;
list.add( "item1" ) ;
list.add( "item2" ) ;
var old:= list.set( 1 , "ITEM2" ) ;
trace("list : " + list + ", old : " + old) ; // list : {item1,ITEM2}, old : item2
Parameters
index:uint — index of element to replace.
| |
o:* — element to be stored at the specified position.
|
* — the element previously at the specified position.
|
| size | () | method |
public function size():uintReturns the number of elements in this list.
Example :
import system.data.lists.LinkedList ;
var list:LinkedList = new LinkedList() ;
list.add("item1") ;
list.add("item2") ;
trace(list.size()) ; // 2
Returnsuint — the number of elements in this list.
|
| subList | () | method |
public function subList(fromIndex:uint, toIndex:uint):ListReturns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
Example :
import system.data.lists.LinkedList ;
var list:LinkedList = new LinkedList() ;
list.add("item1") ;
list.add("item2") ;
list.add("item3") ;
list.add("item4") ;
list.add("item5") ;
trace( list.subList( 0 , 0 ) ) ; // {}
trace( list.subList( 0 , 1 ) ) ; // {item1}
trace( list.subList( 0 , 2 ) ) ; // {item1,item2}
trace( list.subList( 0 , 3 ) ) ; // {item1,item2,item3}
trace( list.subList( 0 , 4 ) ) ; // {item1,item2,item3,item4}
trace( list.subList( 0 , 5 ) ) ; // {item1,item2,item3,item4,item5}
trace( list.subList( 0 , 6 ) ) ; // {item1,item2,item3,item4,item5}
trace( list.subList(2, 4) ) ; // {item3,item4}
trace( list.subList(3, 1) ) ; // {}
Parameters
fromIndex:uint | |
toIndex:uint |
List — a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
|
| toArray | () | method |
public function toArray():ArrayReturns an array containing all of the elements in this list in the correct order.
Example :
import system.data.lists.LinkedList ;
var list:LinkedList = new LinkedList() ;
list.add("item1") ;
list.add("item2") ;
list.add("item3") ;
list.add("item4") ;
trace( list.toArray() ) ; // item1,item2,item3,item4
ReturnsArray — an array containing all of the elements in this list in the correct order.
|
| toSource | () | method |
public function toSource(indent:int = 0):StringReturns the source code string representation of the object.
Parameters
indent:int (default = 0) |
String — the source code string representation of the object.
|
| toString | () | method |
public function toString():StringReturns the string representation of this instance.
ReturnsString — the string representation of this instance.
|