public class GenericEdgeSet<T extends Edge> extends AbstractSet<T> implements EdgeSet<T>, Serializable
EdgeSet
implementation that imposes no restrictions on the type of
edges that may be contained within. This class keeps track of which vertices
are in the set as well, allowing for efficient vertex-based operations.Constructor and Description |
---|
GenericEdgeSet(int rootVertex) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(T e)
Adds the edge to the set only if the edge is connected to the root
vertex.
|
IntSet |
connected()
Returns the set of vertices connected to the root edges.
|
boolean |
connects(int vertex)
Returns true if the root vertex is connected to the provided vertex.
|
boolean |
contains(Object o) |
GenericEdgeSet<T> |
copy(IntSet vertices)
Copies the edges in this set that are connected to any of the vertices in
the provided set.
|
int |
disconnect(int vertex)
Removes all edges instances that connect to the specified vertex,
returning the number of edges that were removed, if any.
|
Set<T> |
getEdges(int vertex)
Returns the set of
Edge instances that connect the root vertex
with this vertex or an empty set if no such edges exist. |
int |
getRoot()
Returns the vertex to which all edges in this set are connected.
|
Iterator<T> |
iterator() |
boolean |
remove(Object o) |
int |
size() |
equals, hashCode, removeAll
addAll, clear, containsAll, isEmpty, retainAll, toArray, toArray, toString
public boolean add(T e)
add
in interface EdgeSet<T extends Edge>
add
in interface Collection<T extends Edge>
add
in interface Set<T extends Edge>
add
in class AbstractCollection<T extends Edge>
true
if the edge was added, false
if the edge was
already present, or if it could not be added to this edge set due
to the root vertex not being connected to the edgepublic IntSet connected()
public boolean connects(int vertex)
public int disconnect(int vertex)
disconnect
in interface EdgeSet<T extends Edge>
public boolean contains(Object o)
public GenericEdgeSet<T> copy(IntSet vertices)
public Set<T> getEdges(int vertex)
Edge
instances that connect the root vertex
with this vertex or an empty set if no such edges exist.public int getRoot()
public boolean remove(Object o)
Copyright © 2012. All Rights Reserved.