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

## jgame.impl
Class SortedArray

    java.lang.Object
      jgame.impl.SortedArray

    public class SortedArray

extends java.lang.Object

Data structure that can be used as replacement for Hashtable<String> for fast sorted enumeration of its elements. It can get and put like a Hashtable. Get uses binary search, and is a little, but not much, slower than Hashtable.get. Put and remove are expensive as they require shifting the array (algorithm duration is linear wrt the array size). It is possible to put or remove multiple elements at a time (using a second SortedArray), which is faster.

Array enumeration is done by simply traversing the keys and/or values array, which are filled with elements from 0 to size, exclusive. This is about 10 times faster than using the Hashtable.getElements/getKeys enumerators, and the elements are sorted (in ascending order).

SortedArray grows automatically to accommodate the required elements. It starts with given initialcapacity and grows with increments initialcapacity each time the capacity is exceeded.

Field Summary
`java.lang.String[]` | `keys`
`int` | `size`
`java.lang.Object[]` | `values`

Constructor Summary
`SortedArray(int initialcapacity)`

Method Summary
`void` | `clear()`
`int` | `get(java.lang.String key)`
`static void` | `main(java.lang.String[] args)` test method
`void` | `put(SortedArray elem)`
`void` | `put(java.lang.String key, java.lang.Object value)`
`void` | `remove(SortedArray elem)`
`void` | `remove(java.lang.String key)`
`java.lang.String` | `toString()`

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

Field Detail

### size

    public int size

### keys

    public java.lang.String[] keys

### values

    public java.lang.Object[] values

Constructor Detail

### SortedArray

    public SortedArray(int initialcapacity)

Method Detail

### clear

    public void clear()

### put

    public void put(SortedArray elem)

### put

    public void put(java.lang.String key,
                    java.lang.Object value)

### remove

    public void remove(java.lang.String key)

### remove

    public void remove(SortedArray elem)

### get

    public int get(java.lang.String key)

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### main

    public static void main(java.lang.String[] args)

  test method

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