edu.neu.ccs.demeterf.lib
Class Map<Key,Val>
java.lang.Object
edu.neu.ccs.demeterf.lib.Map<Key,Val>
- All Implemented Interfaces:
- java.lang.Iterable<Entry<Key,Val>>
public class Map<Key,Val>
- extends java.lang.Object
- implements java.lang.Iterable<Entry<Key,Val>>
Represents a Map of comparable Keys to any old Values, implemented with RBTrees.
The Key requires a Comparator, but if Key is Comparable, you can simply
supply the type to the createor functions. Also see Map.Entry.
Nested Class Summary |
static class |
Map.Merge<Val>
Function Class to help in the merging of Maps. |
static class |
Map.Transform<X,Y>
Trnasformer for Values o fa given Map |
static class |
Map.tree
Field Class |
Method Summary |
boolean |
containsKey(Key k)
Does this Map contain the given Key? |
static
<Key extends java.lang.Comparable<Key>,Val>
Map<Key,Val> |
|
create()
Create an Empty Map of *Comparable* Elements. |
static
|
create(java.util.Comparator<Key> c)
Create an Empty Map using the given Comparator to compare elements. |
static
<Key extends java.lang.Comparable<Key>,Val>
Map<Key,Val> |
|
create(List<Entry<Key,Val>> l)
Create a Map from the given list of Entries, with Comparable Keys. |
static
|
create(List<Entry<Key,Val>> l,
java.util.Comparator<Key> c)
Create a Map from the given list of Entries, with the given Comparator. |
static
<Key extends java.lang.Comparable<Key>,Val>
Map<Key,Val> |
|
create(List<Key> ks,
List<Val> vs)
Create a Map from the given list of Entries using the given Comparator. |
static
|
create(List<Key> ks,
List<Val> vs,
java.util.Comparator<Key> c)
Create a Map from the given list of Entries using the given Comparator. |
Val |
get(Key k)
Get the Value that the given Key is mapped to. |
int |
hashCode()
Retur this Maps HashCode |
static
|
hashMap()
Create a Map that uses Hashcode to compare Keys. |
static
|
hashMap(List<Entry<Key,Val>> l)
Create a Map from the given Entry List that uses Hashcode to compare Keys. |
static
|
hashMap(List<Key> ks,
List<Val> vs)
Create a Map from the given Key and Value Lists that uses Hashcode to compare Keys. |
boolean |
isEmpty()
Is this Map Empty? |
java.util.Iterator<Entry<Key,Val>> |
iterator()
Return an Iterator over the Entries in this Map, in Key order. |
List<Key> |
keys()
Reutrn a List of the Keys contained in this Map. |
Map<Key,Val> |
merge(Key k,
Val v,
Map.Merge<Val> m)
Merge the given Map into this one, using the given Merge function object
to merge the elements of matching Keys |
Map<Key,Val> |
merge(Map<Key,Val> s)
Merge the given Map into this one, ignoring duplicate mappings. |
Map<Key,Val> |
merge(Map<Key,Val> s,
Map.Merge<Val> m)
Merge the given Map into this one, using the given Merge function object
to merge the elements of matching Keys |
Map<Key,Val> |
put(Key k,
Val v)
Return a new Map with the given Mapping (Entry) added. |
Map<Key,Val> |
remap(Key k,
Val v)
Return a new Map with the given Mapping added or updated if it exists. |
Map<Key,Val> |
remove(Key k)
Return a new Map that does not include the given key |
int |
size()
Return the number of elements in this Map |
java.util.Map<Key,Val> |
toJavaMap()
Convert this Map into a java.util.Map |
List<Entry<Key,Val>> |
toList()
Return all the Entries in this Map as a list, in Key order. |
java.lang.String |
toString()
Produce a String representation of this Map. |
java.lang.String |
toTreeString()
Produce a String representation of this Map. |
|
transformValues(List.Map<Val,NVal> t)
Transform Each of the Keys |
List<Val> |
values()
Reutrn a List of the Values contained in this Map. |
Methods inherited from class java.lang.Object |
equals, getClass, notify, notifyAll, wait, wait, wait |
Map
public Map(List<Entry<Key,Val>> l)
- Create a Map from the given list of Entries. The Key must implement
Comparable<Key>
Map
public Map(RBTree<Entry<Key,Val>> t)
- Create a Map from the given RBTree of Entries.
transformValues
public <NVal> Map<Key,NVal> transformValues(List.Map<Val,NVal> t)
- Transform Each of the Keys
create
public static <Key extends java.lang.Comparable<Key>,Val> Map<Key,Val> create()
- Create an Empty Map of *Comparable* Elements.
create
public static <Key,Val> Map<Key,Val> create(java.util.Comparator<Key> c)
- Create an Empty Map using the given Comparator to compare elements.
create
public static <Key extends java.lang.Comparable<Key>,Val> Map<Key,Val> create(List<Entry<Key,Val>> l)
- Create a Map from the given list of Entries, with Comparable Keys.
create
public static <Key,Val> Map<Key,Val> create(List<Entry<Key,Val>> l,
java.util.Comparator<Key> c)
- Create a Map from the given list of Entries, with the given Comparator.
create
public static <Key extends java.lang.Comparable<Key>,Val> Map<Key,Val> create(List<Key> ks,
List<Val> vs)
- Create a Map from the given list of Entries using the given Comparator.
create
public static <Key,Val> Map<Key,Val> create(List<Key> ks,
List<Val> vs,
java.util.Comparator<Key> c)
- Create a Map from the given list of Entries using the given Comparator.
hashMap
public static <Key,Val> Map<Key,Val> hashMap()
- Create a Map that uses Hashcode to compare Keys.
hashMap
public static <Key,Val> Map<Key,Val> hashMap(List<Entry<Key,Val>> l)
- Create a Map from the given Entry List that uses Hashcode to compare Keys.
hashMap
public static <Key,Val> Map<Key,Val> hashMap(List<Key> ks,
List<Val> vs)
- Create a Map from the given Key and Value Lists that uses Hashcode to compare Keys.
size
public int size()
- Return the number of elements in this Map
containsKey
public boolean containsKey(Key k)
- Does this Map contain the given Key?
isEmpty
public boolean isEmpty()
- Is this Map Empty?
put
public Map<Key,Val> put(Key k,
Val v)
- Return a new Map with the given Mapping (Entry) added.
remap
public Map<Key,Val> remap(Key k,
Val v)
- Return a new Map with the given Mapping added or updated if it exists.
get
public Val get(Key k)
- Get the Value that the given Key is mapped to.
remove
public Map<Key,Val> remove(Key k)
- Return a new Map that does not include the given key
merge
public Map<Key,Val> merge(Map<Key,Val> s)
- Merge the given Map into this one, ignoring duplicate mappings.
merge
public Map<Key,Val> merge(Map<Key,Val> s,
Map.Merge<Val> m)
- Merge the given Map into this one, using the given Merge function object
to merge the elements of matching Keys
merge
public Map<Key,Val> merge(Key k,
Val v,
Map.Merge<Val> m)
- Merge the given Map into this one, using the given Merge function object
to merge the elements of matching Keys
keys
public List<Key> keys()
- Reutrn a List of the Keys contained in this Map.
values
public List<Val> values()
- Reutrn a List of the Values contained in this Map.
toList
public List<Entry<Key,Val>> toList()
- Return all the Entries in this Map as a list, in Key order.
iterator
public java.util.Iterator<Entry<Key,Val>> iterator()
- Return an Iterator over the Entries in this Map, in Key order.
- Specified by:
iterator
in interface java.lang.Iterable<Entry<Key,Val>>
toString
public java.lang.String toString()
- Produce a String representation of this Map.
- Overrides:
toString
in class java.lang.Object
toTreeString
public java.lang.String toTreeString()
- Produce a String representation of this Map.
toJavaMap
public java.util.Map<Key,Val> toJavaMap()
- Convert this Map into a java.util.Map
hashCode
public int hashCode()
- Retur this Maps HashCode
- Overrides:
hashCode
in class java.lang.Object