Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.basex.util
Class TokenSet

    java.lang.Object
      org.basex.util.TokenSet

Direct Known Subclasses:
  FNIndex, IntMap, MemValues, Names, ObjectMap, StopWords, TokenMap

    public class TokenSet

extends Object

This is a simple hash set, storing keys in byte arrays. The `TokenMap` class extends it to a hash map.

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

Constructor Summary
`TokenSet()` Constructor.
`TokenSet(DataInput in)` Constructor.

Method Summary
`int` | `add(byte[] key)` Indexes the specified key and returns the offset of the added key.
`int` | `delete(byte[] key)` Deletes the specified key.
`int` | `id(byte[] key)` Returns the id of the specified key or 0 if key was not found.
`byte[]` | `key(int i)` Returns the specified key.
`byte[][]` | `keys()` Returns the hash keys.
`void` | `read(DataInput in)` Reads the token set from the specified input.
`int` | `size()` Returns number of entries.
`void` | `write(DataOutput out)` Writes the token set to the specified output.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TokenSet

    public TokenSet()

  Constructor.

### TokenSet

    public TokenSet(DataInput in)
             throws IOException

  Constructor.

  Parameters:
    `in` - input stream
  Throws:
    `IOException` - I/O exception

Method Detail

### read

    public void read(DataInput in)
              throws IOException

  Reads the token set from the specified input.

  Parameters:
    `in` - input stream
  Throws:
    `IOException` - I/O exception

### write

    public void write(DataOutput out)
               throws IOException

  Writes the token set to the specified output.

  Parameters:
    `out` - output stream
  Throws:
    `IOException` - I/O exception

### add

    public final int add(byte[] key)

  Indexes the specified key and returns the offset of the added key. If the key exists already, a negative offset is returned.

  Parameters:
    `key` - key
  Returns:
    offset of added key, negative offset otherwise

### delete

    public final int delete(byte[] key)

  Deletes the specified key.

  Parameters:
    `key` - key
  Returns:
    deleted key or 0

### id

    public final int id(byte[] key)

  Returns the id of the specified key or 0 if key was not found.

  Parameters:
    `key` - key to be found
  Returns:
    id or 0 if nothing was found

### key

    public final byte[] key(int i)

  Returns the specified key.

  Parameters:
    `i` - key index
  Returns:
    key

### keys

    public final byte[][] keys()

  Returns the hash keys.

  Returns:
    keys

### size

    public final int size()

  Returns number of entries.

  Returns:
    number of entries

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD