java.io
Class ObjectOutputStream.HandleTable

java.lang.Object
  extended byjava.io.ObjectOutputStream.HandleTable
Enclosing class:
ObjectOutputStream

private static class ObjectOutputStream.HandleTable
extends Object

Lightweight identity hash table which maps objects to integer handles, assigned in ascending order.


Field Summary
private  float loadFactor
           
private  int[] next
           
private  Object[] objs
           
private  int size
           
private  int[] spine
           
private  int threshold
           
 
Constructor Summary
(package private) ObjectOutputStream.HandleTable(int initialCapacity, float loadFactor)
          Creates new HandleTable with given capacity and load factor.
 
Method Summary
(package private)  int assign(Object obj)
          Assigns next available handle to given object, and returns handle value.
(package private)  void clear()
          Resets table to its initial (empty) state.
private  void growEntries()
          Increases hash table capacity by lengthening entry arrays.
private  void growSpine()
          Expands the hash "spine" -- equivalent to increasing the number of buckets in a conventional hash table.
private  int hash(Object obj)
          Returns hash value for given object.
private  void insert(Object obj, int handle)
          Inserts mapping object -> handle mapping into table.
(package private)  int lookup(Object obj)
          Looks up and returns handle associated with given object, or -1 if no mapping found.
(package private)  int size()
          Returns the number of mappings currently in table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

size

private int size

threshold

private int threshold

loadFactor

private final float loadFactor

spine

private int[] spine

next

private int[] next

objs

private Object[] objs
Constructor Detail

ObjectOutputStream.HandleTable

ObjectOutputStream.HandleTable(int initialCapacity,
                               float loadFactor)
Creates new HandleTable with given capacity and load factor.

Method Detail

assign

int assign(Object obj)
Assigns next available handle to given object, and returns handle value. Handles are assigned in ascending order starting at 0.


lookup

int lookup(Object obj)
Looks up and returns handle associated with given object, or -1 if no mapping found.


clear

void clear()
Resets table to its initial (empty) state.


size

int size()
Returns the number of mappings currently in table.


insert

private void insert(Object obj,
                    int handle)
Inserts mapping object -> handle mapping into table. Assumes table is large enough to accomodate new mapping.


growSpine

private void growSpine()
Expands the hash "spine" -- equivalent to increasing the number of buckets in a conventional hash table.


growEntries

private void growEntries()
Increases hash table capacity by lengthening entry arrays.


hash

private int hash(Object obj)
Returns hash value for given object.