Java Doc for FastList.java in  » Development » Javolution » javolution » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Development » Javolution » javolution.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javolution.util.FastCollection
      javolution.util.FastList

All known Subclasses:   j2me.util.LinkedList,
FastList
public class FastList extends FastCollection implements List,Reusable(Code)

This class represents a linked list with real-time behavior; smooth capacity increase and no memory allocation as long as the list size does not exceed its initial capacity.

All of the operations perform as could be expected for a doubly-linked list ( FastList.addLast insertion / FastList.removeLast() deletion at the end of the list are nonetheless the fastest). Operations that index into the list will traverse the list from the begining or the end whichever is closer to the specified index. Random access operations can be significantly accelerated by FastList.subList splitting the list into smaller ones.

FastList (as for any FastCollection sub-class) supports thread-safe, fast iterations without using iterators.[code] FastList list = new FastList(); for (FastList.Node n = list.head(), end = list.tail(); (n = n.getNext()) != end;) { String value = n.getValue(); // No typecast necessary. }[/code]

FastList are fully Reusable reusable , they maintain internal pools of Node nodes objects. When a node is removed from its list, it is automatically restored to its pool.

Custom list implementations may override the FastList.newNode method in order to return their own Node implementation (with additional fields for example).


author:
   Jean-Marie Dautelle
version:
   4.2, December 18, 2006

Inner Class :public static class Node implements Record,Serializable

Field Summary
static volatile  intONE_VOLATILE
    

Constructor Summary
public  FastList()
     Creates a list of small initial capacity.
public  FastList(String id)
     Creates a persistent list associated to the specified unique identifier (convenience method).
public  FastList(int capacity)
     Creates a list of specified initial capacity; unless the list size reaches the specified capacity, operations on this list will not allocate memory (no lazy object creation).
public  FastList(Collection values)
     Creates a list containing the specified values, in the order they are returned by the collection's iterator.

Method Summary
final public  booleanadd(Object value)
     Appends the specified value to the end of this list (equivalent to FastList.addLast ).
Parameters:
  value - the value to be appended to this list.
final public  voidadd(int index, Object value)
     Inserts the specified value at the specified position in this list.
final public  booleanaddAll(int index, Collection values)
     Inserts all of the values in the specified collection into this list at the specified position.
final public  voidaddBefore(Node next, Object value)
     Inserts the specified value before the specified Node.
Parameters:
  next - the Node before which this value is inserted.
Parameters:
  value - the value to be inserted.
final public  voidaddFirst(Object value)
     Inserts the specified value at the beginning of this list.
public  voidaddLast(Object value)
     Appends the specified value to the end of this list (fast).
final public  voidclear()
    
final public  booleancontains(Object value)
    
final public  voiddelete(Record record)
    
final public  Objectget(int index)
     Returns the value at the specified position in this list.
Parameters:
  index - the index of value to return.
final public  ObjectgetFirst()
     Returns the first value of this list.
final public  ObjectgetLast()
     Returns the last value of this list.
public  FastComparatorgetValueComparator()
    
public  inthashCode()
     Returns the hash code value for this list.
final public  Recordhead()
    
final public  intindexOf(Object value)
     Returns the index in this list of the first occurrence of the specified value, or -1 if this list does not contain this value.
Parameters:
  value - the value to search for.
public  Iteratoriterator()
     Returns a simple iterator over the elements in this list (allocated on the stack when executed in a javolution.context.StackContext StackContext ).
final public  intlastIndexOf(Object value)
     Returns the index in this list of the last occurrence of the specified value, or -1 if this list does not contain this value.
Parameters:
  value - the value to search for.
public  ListIteratorlistIterator()
     Returns a list iterator over the elements in this list (allocated on the stack when executed in a javolution.context.StackContext StackContext ).
public  ListIteratorlistIterator(int index)
     Returns a list iterator from the specified position (allocated on the stack when executed in a javolution.context.StackContext StackContext ). The specified index indicates the first value that would be returned by an initial call to the next method.
public static  FastListnewInstance()
     Returns a new, preallocated or FastList.recycle recycled list instance (on the stack when executing in a javolution.context.StackContextStackContext ).
protected  NodenewNode()
     Returns a new node for this list; this method can be overriden by custom list implementation.
public static  voidrecycle(FastList instance)
     Recycles a list FastList.newInstance() instance immediately (on the stack when executing in a javolution.context.StackContextStackContext ).
final public  Objectremove(int index)
     Removes the value at the specified position in this list. Shifts any subsequent values to the left (subtracts one from their indices).
final public  ObjectremoveFirst()
     Removes and returns the first value of this list.
final public  ObjectremoveLast()
     Removes and returns the last value of this list (fast).
public  voidreset()
    
final public  Objectset(int index, Object value)
     Replaces the value at the specified position in this list with the specified value.
Parameters:
  index - the index of value to replace.
Parameters:
  value - the value to be stored at the specified position.
public  FastListsetValueComparator(FastComparator comparator)
     Sets the comparator to use for value equality.
Parameters:
  comparator - the value comparator.
final public  intsize()
    
final public  ListsubList(int fromIndex, int toIndex)
     Returns a view of the portion of this list between the specified indexes (allocated from the "stack" when executing in a javolution.context.StackContext StackContext ). If the specified indexes are equal, the returned list is empty.
final public  Recordtail()
    
public  Collectionunmodifiable()
    
final public  ObjectvalueOf(Record record)
    

Field Detail
ONE_VOLATILE
static volatile int ONE_VOLATILE(Code)




Constructor Detail
FastList
public FastList()(Code)
Creates a list of small initial capacity.



FastList
public FastList(String id)(Code)
Creates a persistent list associated to the specified unique identifier (convenience method).
Parameters:
  id - the unique identifier for this map.
throws:
  IllegalArgumentException - if the identifier is not unique.
See Also:   javolution.context.PersistentContext.Reference



FastList
public FastList(int capacity)(Code)
Creates a list of specified initial capacity; unless the list size reaches the specified capacity, operations on this list will not allocate memory (no lazy object creation).
Parameters:
  capacity - the initial capacity.



FastList
public FastList(Collection values)(Code)
Creates a list containing the specified values, in the order they are returned by the collection's iterator.
Parameters:
  values - the values to be placed into this list.




Method Detail
add
final public boolean add(Object value)(Code)
Appends the specified value to the end of this list (equivalent to FastList.addLast ).
Parameters:
  value - the value to be appended to this list. true (as per the general contract of theCollection.add method).



add
final public void add(int index, Object value)(Code)
Inserts the specified value at the specified position in this list. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices).
Parameters:
  index - the index at which the specified value is to be inserted.
Parameters:
  value - the value to be inserted.
throws:
  IndexOutOfBoundsException - if (index < 0) || (index > size())



addAll
final public boolean addAll(int index, Collection values)(Code)
Inserts all of the values in the specified collection into this list at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (increases their indices).
Parameters:
  index - the index at which to insert first value from the specifiedcollection.
Parameters:
  values - the values to be inserted into this list. true if this list changed as a result of the call;false otherwise.
throws:
  IndexOutOfBoundsException - if (index < 0) || (index > size())



addBefore
final public void addBefore(Node next, Object value)(Code)
Inserts the specified value before the specified Node.
Parameters:
  next - the Node before which this value is inserted.
Parameters:
  value - the value to be inserted.



addFirst
final public void addFirst(Object value)(Code)
Inserts the specified value at the beginning of this list.
Parameters:
  value - the value to be inserted.



addLast
public void addLast(Object value)(Code)
Appends the specified value to the end of this list (fast).
Parameters:
  value - the value to be inserted.



clear
final public void clear()(Code)



contains
final public boolean contains(Object value)(Code)



delete
final public void delete(Record record)(Code)



get
final public Object get(int index)(Code)
Returns the value at the specified position in this list.
Parameters:
  index - the index of value to return. the value at the specified position in this list.
throws:
  IndexOutOfBoundsException - if (index < 0) || (index >= size())



getFirst
final public Object getFirst()(Code)
Returns the first value of this list. this list's first value.
throws:
  NoSuchElementException - if this list is empty.



getLast
final public Object getLast()(Code)
Returns the last value of this list. this list's last value.
throws:
  NoSuchElementException - if this list is empty.



getValueComparator
public FastComparator getValueComparator()(Code)



hashCode
public int hashCode()(Code)
Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:[code] h = 1; Iterator i = list.iterator(); while (i.hasNext()) { Object obj = i.next(); h = 31 * h + this.getValueComparator().hashCodeOf(obj); }[/code] the hash code value for this list.



head
final public Record head()(Code)



indexOf
final public int indexOf(Object value)(Code)
Returns the index in this list of the first occurrence of the specified value, or -1 if this list does not contain this value.
Parameters:
  value - the value to search for. the index in this list of the first occurrence of the specifiedvalue, or -1 if this list does not contain this value.



iterator
public Iterator iterator()(Code)
Returns a simple iterator over the elements in this list (allocated on the stack when executed in a javolution.context.StackContext StackContext ). an iterator over this list values.



lastIndexOf
final public int lastIndexOf(Object value)(Code)
Returns the index in this list of the last occurrence of the specified value, or -1 if this list does not contain this value.
Parameters:
  value - the value to search for. the index in this list of the last occurrence of the specifiedvalue, or -1 if this list does not contain this value.



listIterator
public ListIterator listIterator()(Code)
Returns a list iterator over the elements in this list (allocated on the stack when executed in a javolution.context.StackContext StackContext ). an iterator over this list values.



listIterator
public ListIterator listIterator(int index)(Code)
Returns a list iterator from the specified position (allocated on the stack when executed in a javolution.context.StackContext StackContext ). The specified index indicates the first value that would be returned by an initial call to the next method. An initial call to the previous method would return the value with the specified index minus one.
Parameters:
  index - index of first value to be returned from thelist iterator (by a call to the next method). a list iterator over the values in this liststarting at the specified position in this list.
throws:
  IndexOutOfBoundsException - if the index is out of range[code](index < 0 || index > size())[/code].



newInstance
public static FastList newInstance()(Code)
Returns a new, preallocated or FastList.recycle recycled list instance (on the stack when executing in a javolution.context.StackContextStackContext ). a new, preallocated or recycled list instance.



newNode
protected Node newNode()(Code)
Returns a new node for this list; this method can be overriden by custom list implementation. a new node.



recycle
public static void recycle(FastList instance)(Code)
Recycles a list FastList.newInstance() instance immediately (on the stack when executing in a javolution.context.StackContextStackContext ).



remove
final public Object remove(int index)(Code)
Removes the value at the specified position in this list. Shifts any subsequent values to the left (subtracts one from their indices). Returns the value that was removed from the list.
Parameters:
  index - the index of the value to removed. the value previously at the specified position.
throws:
  IndexOutOfBoundsException - if (index < 0) || (index >= size())



removeFirst
final public Object removeFirst()(Code)
Removes and returns the first value of this list. this list's first value before this call.
throws:
  NoSuchElementException - if this list is empty.



removeLast
final public Object removeLast()(Code)
Removes and returns the last value of this list (fast). this list's last value before this call.
throws:
  NoSuchElementException - if this list is empty.



reset
public void reset()(Code)



set
final public Object set(int index, Object value)(Code)
Replaces the value at the specified position in this list with the specified value.
Parameters:
  index - the index of value to replace.
Parameters:
  value - the value to be stored at the specified position. the value previously at the specified position.
throws:
  IndexOutOfBoundsException - if (index < 0) || (index >= size())



setValueComparator
public FastList setValueComparator(FastComparator comparator)(Code)
Sets the comparator to use for value equality.
Parameters:
  comparator - the value comparator. this



size
final public int size()(Code)



subList
final public List subList(int fromIndex, int toIndex)(Code)
Returns a view of the portion of this list between the specified indexes (allocated from the "stack" when executing in a javolution.context.StackContext StackContext ). If the specified indexes are equal, the returned list is empty. The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of values from a list: list.subList(from, to).clear(); Similar idioms may be constructed for indexOf and lastIndexOf, and all of the algorithms in the Collections class can be applied to a subList. The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list (structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results).
Parameters:
  fromIndex - low endpoint (inclusive) of the subList.
Parameters:
  toIndex - high endpoint (exclusive) of the subList. a view of the specified range within this list.
throws:
  IndexOutOfBoundsException - if [code](fromIndex < 0 ||toIndex > size || fromIndex < toIndex)[/code]



tail
final public Record tail()(Code)



unmodifiable
public Collection unmodifiable()(Code)



valueOf
final public Object valueOf(Record record)(Code)



Methods inherited from javolution.util.FastCollection
public boolean add(Object value)(Code)(Java Doc)
public boolean addAll(Collection c)(Code)(Java Doc)
public void clear()(Code)(Java Doc)
public boolean contains(Object value)(Code)(Java Doc)
public boolean containsAll(Collection c)(Code)(Java Doc)
abstract public void delete(Record record)(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
public FastComparator getValueComparator()(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
abstract public Record head()(Code)(Java Doc)
final public boolean isEmpty()(Code)(Java Doc)
public Iterator iterator()(Code)(Java Doc)
public boolean remove(Object value)(Code)(Java Doc)
public boolean removeAll(Collection c)(Code)(Java Doc)
public boolean retainAll(Collection c)(Code)(Java Doc)
abstract public int size()(Code)(Java Doc)
abstract public Record tail()(Code)(Java Doc)
public Object[] toArray()(Code)(Java Doc)
public Object/*{ T}*/[] toArray(Object/*{T}*/[] array)(Code)(Java Doc)
final public String toString()(Code)(Java Doc)
public Text toText()(Code)(Java Doc)
public Collection unmodifiable()(Code)(Java Doc)
abstract public Object valueOf(Record record)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.