uk.ed.inf.graph.util.impl
Class EdgeSet<N extends IBasicNode<N,? extends IBasicEdge<N,?>>,E extends IBasicEdge<N,E>>

java.lang.Object
  extended by uk.ed.inf.graph.util.impl.EdgeSet<N,E>
All Implemented Interfaces:
java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>, IEdgeSet<N,E>

public class EdgeSet<N extends IBasicNode<N,? extends IBasicEdge<N,?>>,E extends IBasicEdge<N,E>>
extends java.lang.Object
implements IEdgeSet<N,E>


Constructor Summary
EdgeSet()
           
 
Method Summary
 boolean add(E edge)
           
 boolean addAll(java.util.Collection<? extends E> c)
           
 void clear()
           
 boolean contains(E edge)
           
 boolean contains(int edgeIdx)
          Does an edge with this index exist in the set.
 boolean contains(N thisNode, N thatNode)
          Does the edge set contain at least one edge with these nodes.
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection<?> c)
           
 E get(int edgeIdx)
          Get the edge with the given index.
 java.util.SortedSet<E> get(N thisNode, N thatNode)
          Get the edges that match the given node connectivity.
 java.util.SortedSet<E> getEdgesWith(N thisNode, N other)
          Gets the edges that contain this node as one of its ends.
 boolean hasEdgesWith(N thisNode, N other)
          Does this edge set contain one or more edges associated with this node?
 boolean isEmpty()
           
 java.util.Iterator<E> iterator()
           
 void remove(E edge)
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection<?> c)
           
 boolean retainAll(java.util.Collection<?> c)
           
 int size()
           
 java.lang.Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
equals, hashCode
 

Constructor Detail

EdgeSet

public EdgeSet()
Method Detail

iterator

public java.util.Iterator<E> iterator()
Specified by:
iterator in interface java.lang.Iterable<E extends IBasicEdge<N,E>>
Specified by:
iterator in interface java.util.Collection<E extends IBasicEdge<N,E>>
Specified by:
iterator in interface java.util.Set<E extends IBasicEdge<N,E>>

getEdgesWith

public java.util.SortedSet<E> getEdgesWith(N thisNode,
                                           N other)
Description copied from interface: IEdgeSet
Gets the edges that contain this node as one of its ends.

Specified by:
getEdgesWith in interface IEdgeSet<N extends IBasicNode<N,? extends IBasicEdge<N,?>>,E extends IBasicEdge<N,E>>
Parameters:
thisNode - the node that is the point of reference.
other - The node associated with the edges. Cannot be null.
Returns:
The set of edges containing the matched nodes. The set will contain at least one node.

hasEdgesWith

public boolean hasEdgesWith(N thisNode,
                            N other)
Description copied from interface: IEdgeSet
Does this edge set contain one or more edges associated with this node?

Specified by:
hasEdgesWith in interface IEdgeSet<N extends IBasicNode<N,? extends IBasicEdge<N,?>>,E extends IBasicEdge<N,E>>
Parameters:
thisNode - The node that is the point of reference.
other - The node to be tested. Can be null.
Returns:
True if one or more edges conatin the node, false otherwise.

contains

public boolean contains(int edgeIdx)
Description copied from interface: IEdgeSet
Does an edge with this index exist in the set.

Specified by:
contains in interface IEdgeSet<N extends IBasicNode<N,? extends IBasicEdge<N,?>>,E extends IBasicEdge<N,E>>
Parameters:
edgeIdx - The edge index.
Returns:
True if an edge matching this index was found, false otherwise.

contains

public boolean contains(E edge)

contains

public boolean contains(N thisNode,
                        N thatNode)
Description copied from interface: IEdgeSet
Does the edge set contain at least one edge with these nodes. This assumes a direction to the nodes so if the edges are undirected the method must be called for both orientations of the edge.

Specified by:
contains in interface IEdgeSet<N extends IBasicNode<N,? extends IBasicEdge<N,?>>,E extends IBasicEdge<N,E>>
Parameters:
thisNode - a node the edge may be connected to.
thatNode - another node the edge may be connected to.
Returns:
True if one or more edges has this connectivity, false otherwise.

get

public java.util.SortedSet<E> get(N thisNode,
                                  N thatNode)
Description copied from interface: IEdgeSet
Get the edges that match the given node connectivity. The connectivity is undirected.

Specified by:
get in interface IEdgeSet<N extends IBasicNode<N,? extends IBasicEdge<N,?>>,E extends IBasicEdge<N,E>>
Parameters:
thisNode - a node the edge may be connected to. Cannot be null.
thatNode - another node the edge may be connected to. Cannot be null.
Returns:
The set of edges containing this connectivity. Note that the set is guaranteed to contain at least one edge.

get

public E get(int edgeIdx)
Description copied from interface: IEdgeSet
Get the edge with the given index.

Specified by:
get in interface IEdgeSet<N extends IBasicNode<N,? extends IBasicEdge<N,?>>,E extends IBasicEdge<N,E>>
Parameters:
edgeIdx - The index of the edge to be obtained.
Returns:
The edge with this index. Will not be null.

remove

public void remove(E edge)
Parameters:
edge -
Throws:
java.lang.IllegalArgumentException - if edge not in list

add

public boolean add(E edge)
Specified by:
add in interface java.util.Collection<E extends IBasicEdge<N,E>>
Specified by:
add in interface java.util.Set<E extends IBasicEdge<N,E>>

size

public int size()
Specified by:
size in interface java.util.Collection<E extends IBasicEdge<N,E>>
Specified by:
size in interface java.util.Set<E extends IBasicEdge<N,E>>

addAll

public boolean addAll(java.util.Collection<? extends E> c)
Specified by:
addAll in interface java.util.Collection<E extends IBasicEdge<N,E>>
Specified by:
addAll in interface java.util.Set<E extends IBasicEdge<N,E>>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<E extends IBasicEdge<N,E>>
Specified by:
clear in interface java.util.Set<E extends IBasicEdge<N,E>>

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection<E extends IBasicEdge<N,E>>
Specified by:
contains in interface java.util.Set<E extends IBasicEdge<N,E>>

containsAll

public boolean containsAll(java.util.Collection<?> c)
Specified by:
containsAll in interface java.util.Collection<E extends IBasicEdge<N,E>>
Specified by:
containsAll in interface java.util.Set<E extends IBasicEdge<N,E>>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<E extends IBasicEdge<N,E>>
Specified by:
isEmpty in interface java.util.Set<E extends IBasicEdge<N,E>>

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection<E extends IBasicEdge<N,E>>
Specified by:
remove in interface java.util.Set<E extends IBasicEdge<N,E>>

removeAll

public boolean removeAll(java.util.Collection<?> c)
Specified by:
removeAll in interface java.util.Collection<E extends IBasicEdge<N,E>>
Specified by:
removeAll in interface java.util.Set<E extends IBasicEdge<N,E>>

retainAll

public boolean retainAll(java.util.Collection<?> c)
Specified by:
retainAll in interface java.util.Collection<E extends IBasicEdge<N,E>>
Specified by:
retainAll in interface java.util.Set<E extends IBasicEdge<N,E>>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<E extends IBasicEdge<N,E>>
Specified by:
toArray in interface java.util.Set<E extends IBasicEdge<N,E>>

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface java.util.Collection<E extends IBasicEdge<N,E>>
Specified by:
toArray in interface java.util.Set<E extends IBasicEdge<N,E>>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object