DRCL JavaSim API

drcl.data
Class Map

java.lang.Object
  |
  +--drcl.DrclObj
        |
        +--drcl.data.Map
All Implemented Interfaces:
java.lang.Cloneable, ObjectDuplicable, java.io.Serializable
Direct Known Subclasses:
RadixMap

public class Map
extends DrclObj

A map keeps (MapKey, entry object) pairs in it. Given a MapKey, an entry/entries can be retrieved by exact match, longest match, match, or wildcard match.

See Also:
MapKey, Serialized Form

Field Summary
static java.lang.Class BEST_CLASS_FOR_LONGEST_MATCH
           
protected  java.lang.Object[] entry
           
protected  MapKey[] key
           
static java.lang.String MATCH_ALL
           
static java.lang.String MATCH_EXACT
           
static java.lang.String MATCH_LONGEST
           
static java.lang.String MATCH_WILDCARD
           
protected  int size
           
 
Constructor Summary
Map()
           
 
Method Summary
 void addEntry(MapKey key_, java.lang.Object entry_)
          Add the key-entry pair to the Map.
 boolean anyMatch(BitSet key_)
           
 java.lang.String binaryRepresentation()
          Prints out the content of this map and represents the keys in the binary form.
 java.lang.String binaryRepresentation(boolean skipLeadingZeros_)
          Prints out the content of this map and represents the keys in the binary form.
 java.lang.String binaryRepresentation(int length_)
          Prints out the content of this map and represents the keys in the binary form.
 java.lang.String diag()
          Printout for diagnosis.
 void duplicate(java.lang.Object source_)
          opies the content of the source_ object to this object.
 java.lang.Object get(BitSet bs_, java.lang.String matchType_)
          For "longest match" and "match all".
 java.lang.Object get(MapKey key_, java.lang.String matchType_)
          For "exact match" and "wildcard match".
 java.lang.Object[] getAllEntries()
           
 MapKey[] getAllKeys()
           
static Map getBestImplementationForLongestMatch()
           
protected  java.lang.Object getExactMatch(MapKey key_)
          Returns the exact match.
protected  java.lang.Object getLongestMatch(BitSet key_)
          Returns the longest match.
protected  java.lang.Object[] getMatches(BitSet key_)
          Returns all the matches
 int getSize()
          Returns the current size (number of entries) of the map.
protected  java.lang.Object[] getWildcardMatches(MapKey key_)
          Returns all the wildcard matches.
 java.lang.String hexRepresentation()
          Prints out the content of this map and represents the keys in the hex form.
 java.lang.String hexRepresentation(boolean skipLeadingZeros_)
          Prints out the content of this map and represents the keys in the hex form.
 java.lang.String hexRepresentation(int length_)
          Prints out the content of this map and represents the keys in the hex form.
 java.lang.String info()
          Prints out the content of this map and represents the keys by the indices of 1's.
 java.lang.String numberRepresentation()
          Prints out the content of this map and represents the keys in the form of long integers.
 java.lang.Object remove(BitSet bs_, java.lang.String matchType_)
          For "longest match" and "match all".
 java.lang.Object remove(MapKey key_, java.lang.String matchType_)
          For "exact match" and "wildcard match".
 void removeEntry(java.lang.Object entry_)
           
protected  java.lang.Object removeExactMatch(MapKey key_)
          Removes the exact match.
protected  java.lang.Object removeLongestMatch(BitSet key_)
          Removes the longest match.
protected  java.lang.Object[] removeMatches(BitSet key_)
          Removes all the matches
protected  java.lang.Object[] removeWildcardMatches(MapKey key_)
          Removes all the wildcard matches.
 void reset()
          Removes all the entries.
 
Methods inherited from class drcl.DrclObj
clone, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BEST_CLASS_FOR_LONGEST_MATCH

public static java.lang.Class BEST_CLASS_FOR_LONGEST_MATCH

MATCH_EXACT

public static final java.lang.String MATCH_EXACT

MATCH_LONGEST

public static final java.lang.String MATCH_LONGEST

MATCH_ALL

public static final java.lang.String MATCH_ALL

MATCH_WILDCARD

public static final java.lang.String MATCH_WILDCARD

key

protected MapKey[] key

entry

protected java.lang.Object[] entry

size

protected int size
Constructor Detail

Map

public Map()
Method Detail

getBestImplementationForLongestMatch

public static final Map getBestImplementationForLongestMatch()

reset

public void reset()
Removes all the entries.

duplicate

public void duplicate(java.lang.Object source_)
Description copied from class: DrclObj
opies the content of the source_ object to this object. he subclass must implement this method to realize DrclObj.clone().
Overrides:
duplicate in class DrclObj

addEntry

public void addEntry(MapKey key_,
                     java.lang.Object entry_)
Add the key-entry pair to the Map. No check is done for duplicate keys.
Parameters:
key_ - the key.
entry_ - the entry.

get

public java.lang.Object get(MapKey key_,
                            java.lang.String matchType_)
For "exact match" and "wildcard match".
See Also:
for "longest match" and "match all".

get

public java.lang.Object get(BitSet bs_,
                            java.lang.String matchType_)
For "longest match" and "match all".
See Also:
for "exact match" and "wildcard match".

getLongestMatch

protected java.lang.Object getLongestMatch(BitSet key_)
Returns the longest match.
Parameters:
key_ - the key to match.
Returns:
the entry with the key matching the argument with largest number of bits.

getExactMatch

protected java.lang.Object getExactMatch(MapKey key_)
Returns the exact match.
Parameters:
key_ - the key to match.
Returns:
the entry with the key exactly matching the argument.

anyMatch

public boolean anyMatch(BitSet key_)
Parameters:
key_ - the key to match.
Returns:
true if a key that matches the argument exists.

getMatches

protected java.lang.Object[] getMatches(BitSet key_)
Returns all the matches
Parameters:
key_ - the key to match.
Returns:
all the entries with the keys matching the argument.

getWildcardMatches

protected java.lang.Object[] getWildcardMatches(MapKey key_)
Returns all the wildcard matches. The mask used to match two keys is the union of the two keys' masks.
Parameters:
key_ - the key to match.
Returns:
all the entries with the keys matching the argument in the wildcard fashion.

remove

public java.lang.Object remove(MapKey key_,
                               java.lang.String matchType_)
For "exact match" and "wildcard match".
See Also:
for "longest match" and "match all".

remove

public java.lang.Object remove(BitSet bs_,
                               java.lang.String matchType_)
For "longest match" and "match all".
See Also:
for "exact match" and "wildcard match".

removeLongestMatch

protected java.lang.Object removeLongestMatch(BitSet key_)
Removes the longest match.
Parameters:
key_ - the key to match.
Returns:
the entry with the key matching the argument with largest number of bits.

removeExactMatch

protected java.lang.Object removeExactMatch(MapKey key_)
Removes the exact match.
Parameters:
key_ - the key to match.
Returns:
the entry with the key exactly matching the argument.

removeMatches

protected java.lang.Object[] removeMatches(BitSet key_)
Removes all the matches
Parameters:
key_ - the key to match.
Returns:
all the entries with the keys matching the argument.

removeWildcardMatches

protected java.lang.Object[] removeWildcardMatches(MapKey key_)
Removes all the wildcard matches. The mask used to match two keys is the union of the two keys' masks.
Parameters:
key_ - the key to match.
Returns:
all the entries with the keys matching the argument in the wildcard fashion.

removeEntry

public void removeEntry(java.lang.Object entry_)

getAllEntries

public java.lang.Object[] getAllEntries()

getAllKeys

public MapKey[] getAllKeys()

getSize

public int getSize()
Returns the current size (number of entries) of the map.

info

public java.lang.String info()
Prints out the content of this map and represents the keys by the indices of 1's.

diag

public java.lang.String diag()
Printout for diagnosis.

numberRepresentation

public java.lang.String numberRepresentation()
Prints out the content of this map and represents the keys in the form of long integers.

binaryRepresentation

public java.lang.String binaryRepresentation()
Prints out the content of this map and represents the keys in the binary form.

binaryRepresentation

public java.lang.String binaryRepresentation(boolean skipLeadingZeros_)
Prints out the content of this map and represents the keys in the binary form.
See Also:
MapKey.binaryRepresentation(boolean).

binaryRepresentation

public java.lang.String binaryRepresentation(int length_)
Prints out the content of this map and represents the keys in the binary form.
See Also:
MapKey.binaryRepresentation(int).

hexRepresentation

public java.lang.String hexRepresentation()
Prints out the content of this map and represents the keys in the hex form.

hexRepresentation

public java.lang.String hexRepresentation(boolean skipLeadingZeros_)
Prints out the content of this map and represents the keys in the hex form.
See Also:
MapKey.hexRepresentation(boolean).

hexRepresentation

public java.lang.String hexRepresentation(int length_)
Prints out the content of this map and represents the keys in the hex form.
See Also:
MapKey.hexRepresentation(int).

DRCL JavaSim API

Copyright © 2001 - DRCL, OSU     ~ Back to JavaSim Home ~