net.walend.lyophil.memory
Class TransientSingleValueIndex

java.lang.Object
  |
  +--net.walend.lyophil.memory.TransientSingleValueIndex
All Implemented Interfaces:
SingleValueIndex

public class TransientSingleValueIndex
extends java.lang.Object
implements SingleValueIndex

This class implements SingleValueIndex using a pair of Maps.

Since:
20010109
Author:
David Walend

Field Summary
private  MutableMap idsToKeys
           
private  MutableMap keysToIDs
           
 
Constructor Summary
TransientSingleValueIndex()
           
 
Method Summary
 void clear()
           
 boolean containsIdentifier(java.io.Serializable id)
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsPair(java.lang.Object key, java.io.Serializable id)
           
protected  MutableMap createIDsToKeys()
           
protected  MutableMap createKeysToIDs()
           
 java.io.Serializable get(java.lang.Object key)
           
 Set getKeys()
           
 boolean isEmpty()
          Returns true if this collection contains no elements.
 java.util.Iterator keyIterator()
           
 void put(java.lang.Object key, java.io.Serializable id)
          Puts the key id pair into the index.
 void remove(java.io.Serializable id)
           
 int size()
          Returns the number of elements in this collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keysToIDs

private MutableMap keysToIDs

idsToKeys

private MutableMap idsToKeys
Constructor Detail

TransientSingleValueIndex

public TransientSingleValueIndex()
Method Detail

createKeysToIDs

protected MutableMap createKeysToIDs()

createIDsToKeys

protected MutableMap createIDsToKeys()

size

public int size()
Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Specified by:
size in interface SingleValueIndex

isEmpty

public boolean isEmpty()
Returns true if this collection contains no elements.

Specified by:
isEmpty in interface SingleValueIndex

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface SingleValueIndex

containsIdentifier

public boolean containsIdentifier(java.io.Serializable id)
Specified by:
containsIdentifier in interface SingleValueIndex

containsPair

public boolean containsPair(java.lang.Object key,
                            java.io.Serializable id)

get

public java.io.Serializable get(java.lang.Object key)
Specified by:
get in interface SingleValueIndex

put

public void put(java.lang.Object key,
                java.io.Serializable id)
         throws KeyDuplicatedException
Puts the key id pair into the index. if the id is already in the index (if the key is not in use (remove the old key and put the pair in the index) else (if the key and id are already in the index (do nothing) else (throw a KeyDuplicatedException))) else (if the key is not in use (put the pair in the index) else throw a KeyDuplicatedException)

Specified by:
put in interface SingleValueIndex

remove

public void remove(java.io.Serializable id)
Specified by:
remove in interface SingleValueIndex

clear

public void clear()
Specified by:
clear in interface SingleValueIndex

getKeys

public Set getKeys()
Specified by:
getKeys in interface SingleValueIndex

keyIterator

public java.util.Iterator keyIterator()
Specified by:
keyIterator in interface SingleValueIndex


Copyright (c) 2000, 2001, David Walend