org.cruxframework.crux.core.client.collection
Class FastList<V>

java.lang.Object
  extended by org.cruxframework.crux.core.client.collection.FastList<V>
Type Parameters:
V - value type

public class FastList<V>
extends Object

Lightweight List implementation. This implementation has a superior performance compared to ArrayList. It uses native javascript implementation on production to increase performance.

Author:
Thiago da Rosa de Bustamante

Constructor Summary
FastList()
          Constructor
 
Method Summary
 void add(int beforeIndex, V value)
          Insert the given element right before the specified position.
 void add(V value)
          Insert the given element at the end of the list.
 void clear()
          Remove all elements on this list
 boolean contains(V value)
          Check if the the list contains the specified value
 V extractFirst()
          Retrieve the first element and remove it from the list
 V get(int index)
          Retrieve an element from the list, based on the specified index
 int indexOf(V value)
          Retrieve the position of the given element on this list.
 V remove(int index)
          Remove the element at the given position.
 boolean remove(V value)
          Remove the given element from the list.
 void set(int index, V value)
          Set the given element into the specified position on this list.
 int size()
          Return the list size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FastList

public FastList()
Constructor

Method Detail

get

public final V get(int index)
Retrieve an element from the list, based on the specified index

Parameters:
index - element position
Returns:
element from list

extractFirst

public final V extractFirst()
Retrieve the first element and remove it from the list

Returns:
first element

add

public final void add(V value)
Insert the given element at the end of the list.

Parameters:
value - element to add

add

public final void add(int beforeIndex,
                      V value)
Insert the given element right before the specified position.

Parameters:
beforeIndex - position to put the element
value - element to add

contains

public final boolean contains(V value)
Check if the the list contains the specified value

Parameters:
value - value to search
Returns:
true if the element is present inside the list

remove

public final V remove(int index)
Remove the element at the given position.

Parameters:
index - element position
Returns:
the removed element

remove

public boolean remove(V value)
Remove the given element from the list.

Parameters:
value -
Returns:
true if removed

size

public final int size()
Return the list size

Returns:
number of elements on this list

clear

public final void clear()
Remove all elements on this list


indexOf

public final int indexOf(V value)
Retrieve the position of the given element on this list.

Parameters:
value - element to search
Returns:
element position. If not present, return -1;

set

public final void set(int index,
                      V value)
Set the given element into the specified position on this list.

Parameters:
index - element position
value - element to set


Copyright © 2014. All rights reserved.