nl.knowledgeplaza.util
Class SortedOnKeyMap

java.lang.Object
  extended by nl.knowledgeplaza.util.SortedOnKeyMap
All Implemented Interfaces:
Serializable, Cloneable, Map

public class SortedOnKeyMap
extends Object
implements Map, Cloneable, Serializable

SortedMap is a simplistic light-weight Map designed for use when the number of entries is small. It is backed by a ArrayList. TreeMap is not a 100% replacement, since TreeMap does not allow for NULL as a key.

Version:
$Revision: 1.2 $
Author:
$Author: toeukpap $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
SortedOnKeyMap()
          Creates a Map.
SortedOnKeyMap(Comparator comparator)
          Creates a Map.
SortedOnKeyMap(int capacity)
          Creates a SortedMap with specified capacity.
SortedOnKeyMap(Map map)
           
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set entrySet()
          must return the same collection everytime as defined in the Map interface
 int find(Object key)
          find the index of a key
 int findValue(Object value)
          find the index of a key
 Object get(Object key)
           
 boolean isEmpty()
           
 Set keySet()
          Return a set with all keys must return the same collection everytime as defined in the Map interface
 Object put(Object key, Object value)
           
 void putAll(Map t)
           
 Object putBefore(Object refKey, Object key, Object value)
           
 Object remove(Object key)
           
 int size()
           
 String toString()
           
 Collection values()
          must return the same collection everytime as defined in the Map interface
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

SortedOnKeyMap

public SortedOnKeyMap()
Creates a Map.


SortedOnKeyMap

public SortedOnKeyMap(Comparator comparator)
Creates a Map.


SortedOnKeyMap

public SortedOnKeyMap(int capacity)
Creates a SortedMap with specified capacity.


SortedOnKeyMap

public SortedOnKeyMap(Map map)
Method Detail

entrySet

public Set entrySet()
must return the same collection everytime as defined in the Map interface

Specified by:
entrySet in interface Map

put

public Object put(Object key,
                  Object value)
Specified by:
put in interface Map

putBefore

public Object putBefore(Object refKey,
                        Object key,
                        Object value)
Parameters:
refKey -
key -
value - Throws IllegalArgumentException when the refKey does not exist
Returns:
old value

remove

public Object remove(Object key)
Specified by:
remove in interface Map

keySet

public Set keySet()
Return a set with all keys must return the same collection everytime as defined in the Map interface

Specified by:
keySet in interface Map

find

public int find(Object key)
find the index of a key

Returns:
idx (> 0) or -1 when not found

findValue

public int findValue(Object value)
find the index of a key

Returns:
idx (> 0) or -1 when not found

clear

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

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map

get

public Object get(Object key)
Specified by:
get in interface Map

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map

putAll

public void putAll(Map t)
Specified by:
putAll in interface Map

size

public int size()
Specified by:
size in interface Map

values

public Collection values()
must return the same collection everytime as defined in the Map interface

Specified by:
values in interface Map

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011 KnowledgePlaza. All Rights Reserved.