org.basex.data
Class Nodes

java.lang.Object
  extended by org.basex.data.Nodes
All Implemented Interfaces:
Result

public final class Nodes
extends java.lang.Object
implements Result

This is a container for context nodes. Instances of this class are stored in the Context class to reference the currently used nodes.

Author:
Workgroup DBIS, University of Konstanz 2005-08, ISC License, Christian Gruen

Field Summary
 Data data
          Root Node.
 int[] nodes
          Pre values container.
 int size
          Number of stored nodes.
 
Constructor Summary
Nodes(Data d)
          Node Set constructor.
Nodes(int[] n, Data d)
          Node Set constructor.
Nodes(int n, Data d)
          Node Set constructor.
 
Method Summary
 Nodes copy()
          Returns a copy of the node set.
static int[] except(int[] ai, int[] bi)
          Subtracts the second from the first array.
 int find(int p)
          Returns the position of the specified node or the negative value - 1 of the position where it should have been found.
static int[] intersect(int[] ai, int[] bi)
          Intersects two integer arrays via union.
 boolean same(Result v)
          Compares values for equality.
 void serialize(Serializer ser)
          Serializes the complete result.
 void serialize(Serializer ser, int n)
          Serializes the specified result.
 int size()
          Number of values, stored in the result instance.
 void toggle(int p)
          The specified pre value is added to or removed from the context set.
 java.lang.String toString()
           
 void union(int[] p)
          The specified nodes are merged.
static int[] union(int[] ai, int[] bi)
          Merges two integer arrays via union.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nodes

public int[] nodes
Pre values container.


data

public Data data
Root Node.


size

public int size
Number of stored nodes.

Constructor Detail

Nodes

public Nodes(Data d)
Node Set constructor.

Parameters:
d - data reference

Nodes

public Nodes(int n,
             Data d)
Node Set constructor.

Parameters:
n - single node
d - data reference

Nodes

public Nodes(int[] n,
             Data d)
Node Set constructor.

Parameters:
n - node set
d - data reference
Method Detail

find

public int find(int p)
Returns the position of the specified node or the negative value - 1 of the position where it should have been found.

Parameters:
p - pre value
Returns:
true if the node was found

toggle

public void toggle(int p)
The specified pre value is added to or removed from the context set.

Parameters:
p - pre value

union

public void union(int[] p)
The specified nodes are merged.

Parameters:
p - pre value

union

public static int[] union(int[] ai,
                          int[] bi)
Merges two integer arrays via union. Note that the input arrays must be sorted.

Parameters:
ai - first set
bi - second set
Returns:
resulting set

intersect

public static int[] intersect(int[] ai,
                              int[] bi)
Intersects two integer arrays via union. Note that the input arrays must be sorted.

Parameters:
ai - first set
bi - second set
Returns:
resulting set

except

public static int[] except(int[] ai,
                           int[] bi)
Subtracts the second from the first array. Note that the input arrays must be sorted.

Parameters:
ai - first set
bi - second set
Returns:
resulting set

size

public int size()
Number of values, stored in the result instance.

Specified by:
size in interface Result
Returns:
number of values

copy

public Nodes copy()
Returns a copy of the node set.

Returns:
copy

same

public boolean same(Result v)
Compares values for equality.

Specified by:
same in interface Result
Parameters:
v - value to be compared
Returns:
true if values are equal

serialize

public void serialize(Serializer ser)
               throws java.io.IOException
Serializes the complete result.

Specified by:
serialize in interface Result
Parameters:
ser - serializer
Throws:
java.io.IOException - exception

serialize

public void serialize(Serializer ser,
                      int n)
               throws java.io.IOException
Serializes the specified result.

Specified by:
serialize in interface Result
Parameters:
ser - serializer
n - number of result to serialize
Throws:
java.io.IOException - exception

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object