Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.josql.incubator
Class ObjectIndex  view ObjectIndex download ObjectIndex.java

java.lang.Object
  extended byorg.josql.incubator.ObjectIndex
All Implemented Interfaces:
java.util.Comparator

public class ObjectIndex
extends java.lang.Object
implements java.util.Comparator

This is an experimental class aimed at producing an index across a collection of homogeneous objects. It should be noted here that it is the "sorting" of the elements in the List of objects that takes nearly all the time here. Use the sort() 55 method yourself to only perform sort once. Everytime you add an object however the sort status of the List of objects will be invalidated and have to be re-sorted before you have retrieve the objects again.


Field Summary
private  java.lang.Class c
           
private  boolean dirty
           
private  java.util.List indices
           
private  java.util.List objs
           
private  int size
           
private  boolean syncOnAdd
           
 
Constructor Summary
ObjectIndex(java.lang.Class c)
           
 
Method Summary
 void add(java.lang.String name)
           
 void addObject(java.lang.Object o)
           
 int compare(java.lang.Object o, java.util.List keys)
           
 int compare(java.lang.Object o1, java.lang.Object o2)
          Return an integer that is negative, zero or positive depending on whether the first argument is less than, equal to or greater than the second according to this ordering.
 java.util.List getObjects(java.util.List keys)
           
 boolean isSyncOnAdd()
           
 void removeObject(java.lang.Object o)
           
 void setSyncOnAdd(boolean v)
           
 int size()
           
 void sort()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

objs

private java.util.List objs

indices

private java.util.List indices

c

private java.lang.Class c

size

private int size

dirty

private boolean dirty

syncOnAdd

private boolean syncOnAdd
Constructor Detail

ObjectIndex

public ObjectIndex(java.lang.Class c)
Method Detail

isSyncOnAdd

public boolean isSyncOnAdd()

setSyncOnAdd

public void setSyncOnAdd(boolean v)

getObjects

public java.util.List getObjects(java.util.List keys)

size

public int size()

sort

public void sort()

add

public void add(java.lang.String name)

removeObject

public void removeObject(java.lang.Object o)

addObject

public void addObject(java.lang.Object o)

compare

public int compare(java.lang.Object o,
                   java.util.List keys)

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Description copied from interface: java.util.Comparator
Return an integer that is negative, zero or positive depending on whether the first argument is less than, equal to or greater than the second according to this ordering. This method should obey the following contract:
  • if compare(a, b) < 0 then compare(b, a) > 0
  • if compare(a, b) throws an exception, so does compare(b, a)
  • if compare(a, b) < 0 and compare(b, c) < 0 then compare(a, c) < 0
  • if compare(a, b) == 0 then compare(a, c) and compare(b, c) must have the same sign
To be consistent with equals, the following additional constraint is in place:
  • if a.equals(b) or both a and b are null, then compare(a, b) == 0.

Although it is permissible for a comparator to provide an order inconsistent with equals, that should be documented.

Specified by:
compare in interface java.util.Comparator