org.basex.index
Class IdPreMap

java.lang.Object
  extended by org.basex.index.IdPreMap

public class IdPreMap
extends java.lang.Object

ID -> PRE mapping.

Author:
BaseX Team 2005-12, BSD License, Dimitar Popov

Constructor Summary
IdPreMap(int id)
          Constructor.
IdPreMap(IOFile f)
          Construct a map by reading it from a file.
 
Method Summary
 void delete(int pre, int id, int c)
          Delete records.
 void insert(int pre, int id, int c)
          Insert new record.
 int pre(int id)
          Find the PRE value of a given ID.
 int[] pre(int[] ids, int off, int len)
          Find the PRE values of a given list of IDs.
 int size()
          Size of the map.
 java.lang.String toString()
           
 void write(IOFile f)
          Write the map to the specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IdPreMap

public IdPreMap(int id)
Constructor.

Parameters:
id - last inserted ID

IdPreMap

public IdPreMap(IOFile f)
         throws java.io.IOException
Construct a map by reading it from a file.

Parameters:
f - file to read from
Throws:
java.io.IOException - I/O error while reading from the file
Method Detail

write

public void write(IOFile f)
           throws java.io.IOException
Write the map to the specified file.

Parameters:
f - file to write to
Throws:
java.io.IOException - I/O error while writing to the file

pre

public int pre(int id)
Find the PRE value of a given ID.

Parameters:
id - ID
Returns:
PRE or -1 if the ID is already deleted

pre

public int[] pre(int[] ids,
                 int off,
                 int len)
Find the PRE values of a given list of IDs.

Parameters:
ids - IDs
off - start position in ids (inclusive)
len - number of ids
Returns:
a sorted array of PRE values

insert

public void insert(int pre,
                   int id,
                   int c)
Insert new record.

Parameters:
pre - record PRE
id - record ID
c - number of inserted records

delete

public void delete(int pre,
                   int id,
                   int c)
Delete records.

Parameters:
pre - PRE of the first record
id - ID of the first deleted record
c - number of deleted records

toString

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

size

public int size()
Size of the map.

Returns:
number of stored tuples.