FileDocCategorySizeDatePackage
BTreeSet.javaAPI DocApache Poi 3.0.130249Mon Jan 01 18:55:22 GMT 2007org.apache.poi.hdf.model.util

BTreeSet

public class BTreeSet extends AbstractSet

Fields Summary
public BTreeNode
root
private Comparator
comparator
private int
order
private int
size
Constructors Summary
public BTreeSet()


    /*
     *                             Constructors
     * A no-arg constructor is supported in accordance with the specifications of the
     * java.util.Collections interface.  If the order for the B-Tree is not specified
     * at construction it defaults to 32.
    */

     
    
        this(6);           // Default order for a BTreeSet is 32
    
public BTreeSet(Collection c)

        this(6);           // Default order for a BTreeSet is 32
        addAll(c);
    
public BTreeSet(int order)

        this(order, null);
    
public BTreeSet(int order, Comparator comparator)

        this.order = order;
        this.comparator = comparator;
        root = new BTreeNode(null);
    
Methods Summary
public booleanadd(java.lang.Object x)

        if (x == null) throw new IllegalArgumentException();
        return root.insert(x, -1);
    
public voidclear()

        root = new BTreeNode(null);
        size = 0;
    
private intcompare(java.lang.Object x, java.lang.Object y)

        return (comparator == null ? ((Comparable)x).compareTo(y) : comparator.compare(x, y));
    
public booleancontains(java.lang.Object x)

        return root.includes(x);
    
public static java.util.ArrayListfindProperties(int start, int end, org.apache.poi.hdf.model.util.BTreeSet$BTreeNode root)

      ArrayList results = new ArrayList();
      BTreeSet.Entry[] entries = root.entries;

      for(int x = 0; x < entries.length; x++)
      {
        if(entries[x] != null)
        {
          BTreeSet.BTreeNode child = entries[x].child;
          PropertyNode xNode = (PropertyNode)entries[x].element;
          if(xNode != null)
          {
            int xStart = xNode.getStart();
            int xEnd = xNode.getEnd();
            if(xStart < end)
            {
              if(xStart >= start)
              {
                if(child != null)
                {
                  ArrayList beforeItems = findProperties(start, end, child);
                  results.addAll(beforeItems);
                }
                results.add(xNode);
              }
              else if(start < xEnd)
              {
                results.add(xNode);
                //break;
              }
            }
            else
            {
              if(child != null)
              {
                ArrayList beforeItems = findProperties(start, end, child);
                results.addAll(beforeItems);
              }
              break;
            }
          }
          else if(child != null)
          {
            ArrayList afterItems = findProperties(start, end, child);
            results.addAll(afterItems);
          }
        }
        else
        {
          break;
        }
      }
      return results;
    
public java.util.Iteratoriterator()

        return new Iterator();
    
public booleanremove(java.lang.Object x)

        if (x == null) return false;
        return root.delete(x, -1);
    
public intsize()

        return size;