Java Doc for FastTable.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.FastTable

All known Subclasses:   j2me.util.ArrayList,
FastTable
public class FastTable extends FastCollection implements List,Reusable,RandomAccess(Code)

This class represents a random access collection with real-time behavior (smooth capacity increase).

This class has the following advantages over the widely used java.util.ArrayList:

  • No large array allocation (for large collections multi-dimensional arrays are employed). The garbage collector is not stressed with large chunk of memory to allocate (likely to trigger a full garbage collection due to memory fragmentation).
  • Support concurrent access/iteration without synchronization if the collection values are not removed/inserted (Ref. javolution.util discussion).

Iterations over the FastTable values are faster when performed using the FastTable.get method rather than using collection records or iterators:[code] for (int i = 0, n = table.size(); i < n; i++) { table.get(i); }[/code]

FastTable supports FastTable.sort sorting in place (quick sort) using the FastCollection.getValueComparator value comparator for the table (no object or array allocation when sorting).

The size of a FastTable can be FastTable.setSize set directly and populated concurrently through the FastTable.set(int,Object) method (e.g. table shared by multiple threads each working on different index ranges).


author:
   Jean-Marie Dautelle
version:
   5.2, August 20, 2007


Field Summary
static volatile  intONE_VOLATILE
    

Constructor Summary
public  FastTable()
     Creates a table of small initial capacity.
public  FastTable(String id)
     Creates a persistent table associated to the specified unique identifier (convenience method).
public  FastTable(int capacity)
     Creates a table of specified initial capacity; unless the table size reaches the specified capacity, operations on this table will not allocate memory (no lazy object creation).
public  FastTable(Collection values)
     Creates a table 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 table.
Parameters:
  value - the value to be appended to this table.
final public  voidadd(int index, Object value)
     Inserts the specified value at the specified position in this table.
final public  booleanaddAll(int index, Collection values)
     Inserts all of the values in the specified collection into this table at the specified position.
final public  voidaddLast(Object value)
     Appends the specified value to the end of this table (fast).
final public  voidclear()
    
final public  booleancontains(Object value)
    
final public  voiddelete(Record record)
    
final public  Objectget(int index)
     Returns the element at the specified index.
Parameters:
  index - index of value to return.
final protected  intgetCapacity()
     Returns the current capacity of this table.
final public  ObjectgetFirst()
     Returns the first value of this table.
final public  ObjectgetLast()
     Returns the last value of this table.
public  FastComparatorgetValueComparator()
    
final public  Recordhead()
    
final public  intindexOf(Object value)
     Returns the index in this table of the first occurrence of the specified value, or -1 if this table does not contain this value.
Parameters:
  value - the value to search for.
public  Iteratoriterator()
     Returns an 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 table of the last occurrence of the specified value, or -1 if this table 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 list iterator being returned does not support insertion/deletion.
Parameters:
  index - the index of first value to be returned from thelist iterator (by a call to the next method).
public static  FastTablenewInstance()
     Returns a new, preallocated or FastTable.recycle recycled table instance (on the stack when executing in a javolution.context.StackContextStackContext ).
public static  voidrecycle(FastTable instance)
     Recycles a table FastTable.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 from this table. Shifts any subsequent values to the left (subtracts one from their indices).
final public  ObjectremoveLast()
     Removes and returns the last value of this table (fast).
final public  voidremoveRange(int fromIndex, int toIndex)
     Removes the values between [fromIndex..toIndex[ from this table.
public  voidreset()
    
final public  Objectset(int index, Object value)
     Replaces the value at the specified position in this table with the specified value.
Parameters:
  index - index of value to replace.
Parameters:
  value - value to be stored at the specified position.
public  voidsetSize(int size)
     Sets the size of this table.
public  FastTablesetValueComparator(FastComparator comparator)
     Sets the comparator to use for value equality or comparison if the collection is ordered (see FastTable.sort() ).
Parameters:
  comparator - the value comparator.
final public  intsize()
    
final public  FastTablesort()
     Sorts this table in place (quick sort) using this table FastCollection.getValueComparator value comparator (smallest first).
final public  ListsubList(int fromIndex, int toIndex)
     Returns a view of the portion of this list between the specified indexes (instance of FastList 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()
    
final public  voidtrimToSize()
     Reduces the capacity of this table to the current size (minimize storage space).
public  Collectionunmodifiable()
    
final public  ObjectvalueOf(Record record)
    

Field Detail
ONE_VOLATILE
static volatile int ONE_VOLATILE(Code)




Constructor Detail
FastTable
public FastTable()(Code)
Creates a table of small initial capacity.



FastTable
public FastTable(String id)(Code)
Creates a persistent table 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



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



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




Method Detail
add
final public boolean add(Object value)(Code)
Appends the specified value to the end of this table.
Parameters:
  value - the value to be appended to this table. 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 table. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices).

Note: If this method is used concurrent access must be synchronized (the table is no more thread-safe).


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 table at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (increases their indices).

Note: If this method is used concurrent access must be synchronized (the table is no more thread-safe).


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())



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



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 element at the specified index.
Parameters:
  index - index of value to return. the value at the specified position in this list.
throws:
  IndexOutOfBoundsException - if (index < 0) || (index >= size())



getCapacity
final protected int getCapacity()(Code)
Returns the current capacity of this table. this table's capacity.



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



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



getValueComparator
public FastComparator getValueComparator()(Code)



head
final public Record head()(Code)



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



iterator
public Iterator iterator()(Code)
Returns an 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 table of the last occurrence of the specified value, or -1 if this table does not contain this value.
Parameters:
  value - the value to search for. the index in this table of the last occurrence of the specifiedvalue, or -1 if this table 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 list iterator being returned does not support insertion/deletion.
Parameters:
  index - the index of first value to be returned from thelist iterator (by a call to the next method). a list iterator of the values in this tablestarting 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 FastTable newInstance()(Code)
Returns a new, preallocated or FastTable.recycle recycled table instance (on the stack when executing in a javolution.context.StackContextStackContext ). a new, preallocated or recycled table instance.



recycle
public static void recycle(FastTable instance)(Code)
Recycles a table FastTable.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 from this table. Shifts any subsequent values to the left (subtracts one from their indices). Returns the value that was removed from the table.

Note: If this method is used concurrent access must be synchronized (the table is no more thread-safe).


Parameters:
  index - the index of the value to removed. the value previously at the specified position.
throws:
  IndexOutOfBoundsException - if (index < 0) || (index >= size())



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



removeRange
final public void removeRange(int fromIndex, int toIndex)(Code)
Removes the values between [fromIndex..toIndex[ from this table.

Note: If this method is used concurrent access must be synchronized (the table is no more thread-safe).


Parameters:
  fromIndex - the beginning index, inclusive.
Parameters:
  toIndex - the ending index, exclusive.
throws:
  IndexOutOfBoundsException - if (fromIndex < 0) || (toIndex < 0) || (fromIndex > toIndex) || (toIndex > this.size())



reset
public void reset()(Code)



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



setSize
public void setSize(int size)(Code)
Sets the size of this table. If the specified size is greater than the current size then null elements are added; otherwise the last elements are removed until the desired size is reached.
Parameters:
  size - the new size.



setValueComparator
public FastTable setValueComparator(FastComparator comparator)(Code)
Sets the comparator to use for value equality or comparison if the collection is ordered (see FastTable.sort() ).
Parameters:
  comparator - the value comparator. this



size
final public int size()(Code)



sort
final public FastTable sort()(Code)
Sorts this table in place (quick sort) using this table FastCollection.getValueComparator value comparator (smallest first). this



subList
final public List subList(int fromIndex, int toIndex)(Code)
Returns a view of the portion of this list between the specified indexes (instance of FastList 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: [code] list.subList(from, to).clear();[/code] 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)



trimToSize
final public void trimToSize()(Code)
Reduces the capacity of this table to the current size (minimize storage space).



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.