net.walend.lyophil.memory
Class TransientMultiValueIndex

java.lang.Object
  |
  +--net.walend.lyophil.memory.TransientMultiValueIndex
All Implemented Interfaces:
MultiValueIndex

public class TransientMultiValueIndex
extends java.lang.Object
implements MultiValueIndex

This class implements MultiValueIndex on top of Maps and Sets.

Use it to create in-memory indicies to help create quicker Diggers.

Since:
20010110
Author:
David Walend

Field Summary
private  MutableMap idsToKeys
           
private  MutableMap keysToSets
           
 
Constructor Summary
TransientMultiValueIndex()
           
 
Method Summary
 void clear()
           
 boolean containsIdentifier(java.io.Serializable id)
           
 boolean containsKey(java.lang.Object key)
           
 int countIdentifiersForKey(java.lang.Object key)
           
protected  MutableMap createIDsToKeys()
           
protected  MutableMap createKeysToSets()
           
protected  MutableSetOfFreezables createSet()
           
 SetOfFreezables get(java.lang.Object key)
          Returns an immutable Set.
 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)
          Removes the id from the index.
 int size()
          Returns the number keys in this index
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keysToSets

private MutableMap keysToSets

idsToKeys

private MutableMap idsToKeys
Constructor Detail

TransientMultiValueIndex

public TransientMultiValueIndex()
Method Detail

createKeysToSets

protected MutableMap createKeysToSets()

createIDsToKeys

protected MutableMap createIDsToKeys()

createSet

protected MutableSetOfFreezables createSet()

size

public int size()
Description copied from interface: MultiValueIndex
Returns the number keys in this index

Specified by:
size in interface MultiValueIndex

isEmpty

public boolean isEmpty()
Description copied from interface: MultiValueIndex
Returns true if this collection contains no elements.

Specified by:
isEmpty in interface MultiValueIndex

containsKey

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

countIdentifiersForKey

public int countIdentifiersForKey(java.lang.Object key)
Specified by:
countIdentifiersForKey in interface MultiValueIndex

containsIdentifier

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

get

public SetOfFreezables get(java.lang.Object key)
Description copied from interface: MultiValueIndex
Returns an immutable Set.

Specified by:
get in interface MultiValueIndex

put

public void put(java.lang.Object key,
                java.io.Serializable id)
Description copied from interface: MultiValueIndex
Puts the key id pair into the index. If the key is already in the index, this method adds the id to the Set for that key. If the key is not in the index, then this method creates a Set for that key, then adds the id to it.

Specified by:
put in interface MultiValueIndex

remove

public void remove(java.io.Serializable id)
Description copied from interface: MultiValueIndex
Removes the id from the index. If this id is the last id in a Set pointed at by a key, then this method also removes the key.

Specified by:
remove in interface MultiValueIndex

clear

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

getKeys

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

keyIterator

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


Copyright (c) 2000, 2001, David Walend