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

## org.basex.util
Class Num

    java.lang.Object
      org.basex.util.Num

    public final class Num

extends java.lang.Object

This class provides operations to compress and decompress integer values in byte arrays to save memory. The first four bytes of the array store the array length. `more()` and `next()` can be called to iterate through the stored values.

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

Constructor Summary
`Num(byte[] array, boolean w)` Constructor for iterating a `Num` instance.

Method Summary
`static byte[]` | `add(byte[] array, byte[] v)` Adds a byte array to the specified array.
`static byte[]` | `add(byte[] array, int val)` Compresses and writes an integer value to the specified byte array.
`static byte[]` | `finish(byte[] array)` Finishes compressed id array.
`int` | `id()` Returns next id.
`static int` | `len(byte[] array, int val)` Returns integer length.
`boolean` | `more()` Checks if more numbers are to be iterated.
`static byte[]` | `newNum()` Returns an empty number array.
`static byte[]` | `newNum(int val)` Creates a new num array.
`void` | `next()` Jumps to next id.
`int` | `pos()` Returns next word position.
`static int` | `read(byte[] array, int pos)` Reads and decompresses an integer value from the specified byte array.
`static int` | `size(byte[] array)` Returns length of the specified array.

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

Constructor Detail

### Num

    public Num(byte[] array,
               boolean w)

  Constructor for iterating a `Num` instance.

  Parameters:
    `array` - array to be iterated
    `w` - flag stating if word positions are stored in the array

Method Detail

### add

    public static byte[] add(byte[] array,
                             byte[] v)

  Adds a byte array to the specified array.

  Parameters:
    `array` - array to be mofified
    `v` - array to be added
  Returns:
    modified array

### add

    public static byte[] add(byte[] array,
                             int val)

  Compresses and writes an integer value to the specified byte array.

  Parameters:
    `array` - array
    `val` - value to be written
  Returns:
    new array

### finish

    public static byte[] finish(byte[] array)

  Finishes compressed id array.

  Parameters:
    `array` - to be finished
  Returns:
    byte array

### id

    public int id()

  Returns next id.

  Returns:
    next id

### len

    public static int len(byte[] array,
                          int val)

  Returns integer length.

  Parameters:
    `array` - array
    `val` - integer value
  Returns:
    value length

### more

    public boolean more()

  Checks if more numbers are to be iterated.

  Returns:
    true if more numbers are found

### newNum

    public static byte[] newNum()

  Returns an empty number array.

  Returns:
    new array

### newNum

    public static byte[] newNum(int val)

  Creates a new num array.

  Parameters:
    `val` - initial value to be written
  Returns:
    new array

### next

    public void next()

  Jumps to next id.

### pos

    public int pos()

  Returns next word position.

  Returns:
    next word position

### read

    public static int read(byte[] array,
                           int pos)

  Reads and decompresses an integer value from the specified byte array.

  Parameters:
    `array` - array
    `pos` - position to parse
  Returns:
    decompressed value

### size

    public static int size(byte[] array)

  Returns length of the specified array.

  Parameters:
    `array` - array to be evaluated
  Returns:
    array length

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