|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap
edu.byu.ece.graph.NodeEdgeMap
public class NodeEdgeMap
Represents a Map between node objects within a DirectedGraph object
and a Collection of Edge objects. The node objects can be a class of any type
while the edge objects within the Collections must be an Edge object.
The Map used between nodes and edges will correspond to either the source nodes of the edge or the sink nodes of the edge. If it uses the source node, this class is "source" mapped. This means that the key of the Map is a source node for all Edge objects in the associated Collection.
If it uses the sink node, this class is "sink" mapped. This means that the key of the Map is a sink node for all Edge objects in the associated Collection.
The mapping must be determined during construction and cannot be changed.
WARNING: If the hash code of a key (node) to this Map changes during run time, the Map will fail to operate correctly. Make sure that the hash code of any node Object cannot change over time.
| Field Summary | |
|---|---|
protected boolean |
_sourceMapped
|
| Constructor Summary | |
|---|---|
NodeEdgeMap(boolean sourceMapped)
Construct a new object. |
|
NodeEdgeMap(int size,
boolean sourceMapped)
Construct a new object with an initial capacity. |
|
NodeEdgeMap(NodeEdgeMap map)
Construct a new object based on the parameter (copy constructor). |
|
| Method Summary | |
|---|---|
boolean |
addEdge(Edge edge)
Add an edge to the Map. |
java.lang.Object |
clone()
Clone this object. |
java.util.Collection<Edge> |
getEdges()
Returns all of the Edges of this Map. |
java.util.Collection |
getEdges(java.lang.Object o)
Helper function that returns a non-null Collection object that is the "value" of the given object in the map. |
java.util.Collection |
getNodes()
Return all of the Nodes in this Map. |
NodeEdgeMap |
invert()
Create a new NodeEdgeMap such that the edges are all inverted and the sourceMapped tag is flipped. |
boolean |
removeEdge(Edge edge)
Remove the given edge from the Map. |
void |
retainEdgesForNodes(java.util.Collection nodes)
Removes all Edges from the given Map (node Object -> Collection of Edges) that do not attach to any of the node Objects passed in. |
void |
trimToSize()
|
| Methods inherited from class java.util.LinkedHashMap |
|---|
clear, containsValue, get, removeEldestEntry |
| Methods inherited from class java.util.HashMap |
|---|
containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values |
| Methods inherited from class java.util.AbstractMap |
|---|
equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
| Field Detail |
|---|
protected boolean _sourceMapped
| Constructor Detail |
|---|
public NodeEdgeMap(int size,
boolean sourceMapped)
size - The initial capacity of the MapsourceMapped - The mapping mode of the object. true indicates a
"source" mapped mapping while false indicates a "sink" mapped mapping.public NodeEdgeMap(boolean sourceMapped)
sourceMapped - The mapping mode of the object. true indicates a
"source" mapped mapping while false indicates a "sink" mapped mapping.public NodeEdgeMap(NodeEdgeMap map)
map - The NodeEdgeMap to copy| Method Detail |
|---|
public java.lang.Object clone()
Object.clone()
clone in class java.util.HashMappublic boolean addEdge(Edge edge)
edge - The edge to add.public boolean removeEdge(Edge edge)
edge - The edge to remove
public java.util.Collection<Edge> getEdges()
public java.util.Collection getNodes()
public void retainEdgesForNodes(java.util.Collection nodes)
If the parameter checkSource is true, only the source of each Edge is examined, if false, only the sink is examined.
public NodeEdgeMap invert()
TODO: get rid of this function?
public java.util.Collection getEdges(java.lang.Object o)
o - The given object
public void trimToSize()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||