Java Doc for TreeArray.java in  » Ajax » zk » org » zkoss » 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 » Ajax » zk » org.zkoss.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.util.AbstractList
   org.zkoss.util.TreeArray

All known Subclasses:   org.zkoss.util.CheckableTreeArray,
TreeArray
public class TreeArray extends AbstractList implements ListX,Cloneable,java.io.Serializable(Code)
Red-black tree based array implementation of List interface. Unlike LinkedList, the random access by index is as fast as log(n). Unlike ArrayList, the insertion is as fast as log(n). It is a great compromise between randown and sequential access.

In additions, it extends the features by also implementing ListX.

The deriving class might override newEntry if it also extends RbEntry; override insert(RbEntry, RbEntry) for adding element; override delete(RbEntry) for removing element; clear() for clearing the whole list.

Also, RbEntry.setElement might be overrided if the deriving class wants to do something when the set method is called.

The iterator method is designed such that next() will proceed correctly even if getElement() throws an exception.

The original algorithm is invented by Henri Chen.
author:
   tomyeh
See Also:   ListX


Inner Class :protected static class RbEntry implements Entry

Field Summary
final protected static  booleanBLACK
    
final protected static  booleanRED
    
protected transient  int_hashCode
    
protected transient  RbEntry_root
    
protected transient  int_size
    

Constructor Summary
public  TreeArray()
    
public  TreeArray(Collection c)
     Constructor with a collection.

Method Summary
public  voidadd(int index, Object element)
    
final public  voidaddAllByOrder(Collection cn)
     Adds all elements by their natural ordering. This array must be sorted into ascending order according to the natural ordering.
final public  voidaddAllByOrder(Collection cn, Comparator c)
     Adds all elements by the specified comparator. This array must be sorted into ascending order according to the specified comparator.
final public  voidaddByOrder(Object element)
     Adds an element by its natural ordering. This array must be sorted into ascending order according to the natural ordering.
final public  voidaddByOrder(Object element, Comparator c)
     Adds an element by the specified comparator. This array must be sorted into ascending order according to the specified comparator.
final public  EntryaddEntry(Entry insertBefore, Object element)
    
final public  EntryaddEntry(int index, Object element)
    
final public  EntryaddEntry(Object element)
    
final protected  RbEntrycheckNotOrphan(Entry entry)
    
final protected  voidcheckRange(int index)
    
final protected  voidcheckRangePlus(int index)
    
public  voidclear()
     Clears the whole list.
public  Objectclone()
    
final protected  voiddecSize()
    
protected  RbEntrydelete(int index)
    
protected  voiddelete(RbEntry p)
     All remove methods are done thru this method.
final public  ListIteratorentryIterator(int index)
    
final public  ListIteratorentryIterator()
    
final protected  RbEntryfirst()
     Returns the first node.
final public  Objectget(int index)
    
final public  ObjectgetByOrder(Object element)
     Gets an element by its natural ordering.
final public  ObjectgetByOrder(Object element, Comparator c)
     Gets an element by its natural ordering.
final public  EntrygetEntry(int index)
    
final protected  RbEntrygetRbEntry(int index)
    
public  inthashCode()
    
final protected  voidincSize()
    
final protected  intindexOfEntry(RbEntry p)
    
final public  intindexOfEntry(Entry p)
    
final protected  voidindexOutOfBounds(int index)
    
final protected  RbEntryinsert(int index, RbEntry p)
    
protected  RbEntryinsert(RbEntry insertBefore, RbEntry p)
     All add methods are done thru this method.
final public  Iteratoriterator()
    
final public  ListIteratorlistIterator(int index)
    
protected  RbEntrynewEntry(Object element)
     Creates an instance of RbEntry.
public  Objectremove(int index)
    
final public  booleanremoveByOrder(Object element)
     Removes an element by its natural ordering. This array must be sorted into ascending order according to the natural ordering.
final public  booleanremoveByOrder(Object element, Comparator c)
     Removes an element by the specified comparator. This array must be sorted into ascending order according to the specified comparator.
final public  voidremoveEntry(Entry p)
    
final public  EntryremoveEntry(int index)
    
final public  intsearch(Object element)
     Searches an element by its natural ordering. This array must be sorted into ascending order according to the natural ordering.
final public  intsearch(Object element, Comparator c)
     Searches an element by the specified comparator. This array must be sorted into ascending order according to the specified comparator.
public  Objectset(int index, Object element)
    
final public  intsize()
    
final public  voidsort()
     Sorts all elements ascendingly by the natural ordering.
final public  voidsort(Comparator c)
     Sorts all elements ascendingly by the specified comparator.

Field Detail
BLACK
final protected static boolean BLACK(Code)



RED
final protected static boolean RED(Code)



_hashCode
protected transient int _hashCode(Code)



_root
protected transient RbEntry _root(Code)



_size
protected transient int _size(Code)




Constructor Detail
TreeArray
public TreeArray()(Code)



TreeArray
public TreeArray(Collection c)(Code)
Constructor with a collection.
Parameters:
  c - the collection to add; null to ignore




Method Detail
add
public void add(int index, Object element)(Code)



addAllByOrder
final public void addAllByOrder(Collection cn)(Code)
Adds all elements by their natural ordering. This array must be sorted into ascending order according to the natural ordering. To sort, either sort or add all elements by order.

All elements are assumed to implement Comparable.




addAllByOrder
final public void addAllByOrder(Collection cn, Comparator c)(Code)
Adds all elements by the specified comparator. This array must be sorted into ascending order according to the specified comparator. To sort, either sort or add all elements by order.



addByOrder
final public void addByOrder(Object element)(Code)
Adds an element by its natural ordering. This array must be sorted into ascending order according to the natural ordering. To sort, either sort or add all elements by order.

All elements are assumed to implement Comparable.




addByOrder
final public void addByOrder(Object element, Comparator c)(Code)
Adds an element by the specified comparator. This array must be sorted into ascending order according to the specified comparator. To sort, either sort or add all elements by order.



addEntry
final public Entry addEntry(Entry insertBefore, Object element)(Code)



addEntry
final public Entry addEntry(int index, Object element)(Code)



addEntry
final public Entry addEntry(Object element)(Code)



checkNotOrphan
final protected RbEntry checkNotOrphan(Entry entry)(Code)
Converts and checks whether it is not orphan



checkRange
final protected void checkRange(int index)(Code)



checkRangePlus
final protected void checkRangePlus(int index)(Code)



clear
public void clear()(Code)
Clears the whole list. Overrides it if the derived class has other data to clear. Note it doesn't call removeEx.

Note clear actually invokes RbEntry.clear to do the real cleanup. Deriving classes might override RbEntry.clear.




clone
public Object clone()(Code)



decSize
final protected void decSize()(Code)



delete
protected RbEntry delete(int index)(Code)



delete
protected void delete(RbEntry p)(Code)
All remove methods are done thru this method. Override it if necessary.



entryIterator
final public ListIterator entryIterator(int index)(Code)



entryIterator
final public ListIterator entryIterator()(Code)



first
final protected RbEntry first()(Code)
Returns the first node.



get
final public Object get(int index)(Code)



getByOrder
final public Object getByOrder(Object element)(Code)
Gets an element by its natural ordering. It is a shortcut of get(search(element)).
See Also:   TreeArray.search(Object) null if not found



getByOrder
final public Object getByOrder(Object element, Comparator c)(Code)
Gets an element by its natural ordering. It is a shortcut of get(search(element, c)).
See Also:   TreeArray.search(Object,Comparator) null if not found



getEntry
final public Entry getEntry(int index)(Code)



getRbEntry
final protected RbEntry getRbEntry(int index)(Code)



hashCode
public int hashCode()(Code)



incSize
final protected void incSize()(Code)



indexOfEntry
final protected int indexOfEntry(RbEntry p)(Code)



indexOfEntry
final public int indexOfEntry(Entry p)(Code)



indexOutOfBounds
final protected void indexOutOfBounds(int index)(Code)



insert
final protected RbEntry insert(int index, RbEntry p)(Code)



insert
protected RbEntry insert(RbEntry insertBefore, RbEntry p)(Code)
All add methods are done thru this method. Override it if necessary.

Note: p is inserted before insertBefore.




iterator
final public Iterator iterator()(Code)



listIterator
final public ListIterator listIterator(int index)(Code)



newEntry
protected RbEntry newEntry(Object element)(Code)
Creates an instance of RbEntry. Override it if necessary



remove
public Object remove(int index)(Code)



removeByOrder
final public boolean removeByOrder(Object element)(Code)
Removes an element by its natural ordering. This array must be sorted into ascending order according to the natural ordering. To sort, either sort or add all elements by order.

All elements are assumed to implement Comparable.




removeByOrder
final public boolean removeByOrder(Object element, Comparator c)(Code)
Removes an element by the specified comparator. This array must be sorted into ascending order according to the specified comparator. To sort, either sort or add all elements by order.



removeEntry
final public void removeEntry(Entry p)(Code)



removeEntry
final public Entry removeEntry(int index)(Code)



search
final public int search(Object element)(Code)
Searches an element by its natural ordering. This array must be sorted into ascending order according to the natural ordering. To sort, either sort or add all elements by order, TreeArray.addByOrder(Object) .

All elements are assumed to implement Comparable. Note: the element argument of this method is passed as the argument of the compareTo method. Thus, it is OK to pass any kind of object, as long as the elements stored in this array is able to detect it.

For example, you might use a String to search the element, and your element's compareTo shall be implemented as follows.

public int compareTo(Object o) {
 return o instanceof String ?
 _name.compareTo((String)o):
 _name.compareTo(((YourClass)o).getName());
 }



search
final public int search(Object element, Comparator c)(Code)
Searches an element by the specified comparator. This array must be sorted into ascending order according to the specified comparator. To sort, either sort or add all elements by order, TreeArray.addByOrder(Object,Comparator) .

All elements are assumed to implement Comparable. Note: the element argument of this method is passed as the argument of the compareTo method. Thus, it is OK to pass any kind of object, as long as the elements stored in this array is able to detect it.




set
public Object set(int index, Object element)(Code)



size
final public int size()(Code)



sort
final public void sort()(Code)
Sorts all elements ascendingly by the natural ordering.

All elements are assumed to implement Comparable.




sort
final public void sort(Comparator c)(Code)
Sorts all elements ascendingly by the specified comparator.



Fields inherited from java.util.AbstractList
protected transient int modCount(Code)(Java Doc)

Methods inherited from java.util.AbstractList
public boolean add(E e)(Code)(Java Doc)
public void add(int index, E element)(Code)(Java Doc)
public boolean addAll(int index, Collection<? extends E> c)(Code)(Java Doc)
public void clear()(Code)(Java Doc)
public boolean equals(Object o)(Code)(Java Doc)
abstract public E get(int index)(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
public int indexOf(Object o)(Code)(Java Doc)
public Iterator<E> iterator()(Code)(Java Doc)
public int lastIndexOf(Object o)(Code)(Java Doc)
public ListIterator<E> listIterator()(Code)(Java Doc)
public ListIterator<E> listIterator(int index)(Code)(Java Doc)
public E remove(int index)(Code)(Java Doc)
protected void removeRange(int fromIndex, int toIndex)(Code)(Java Doc)
public E set(int index, E element)(Code)(Java Doc)
public List<E> subList(int fromIndex, int toIndex)(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.