uk.ed.inf.graph.util.impl
Class DirectedEdgeSet<N extends IDirectedNode<N,? extends IDirectedEdge<N,?>>,E extends IDirectedEdge<N,E>>

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

public class DirectedEdgeSet<N extends IDirectedNode<N,? extends IDirectedEdge<N,?>>,E extends IDirectedEdge<N,E>>
extends java.lang.Object
implements IDirectedEdgeSet<N,E>


Constructor Summary
DirectedEdgeSet()
           
 
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 outNode, N inNode)
          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 outNode, N inNode)
          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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Set
equals, hashCode
 

Constructor Detail

DirectedEdgeSet

public DirectedEdgeSet()
Method Detail

iterator

public java.util.Iterator<E> iterator()
Specified by:
iterator in interface java.lang.Iterable<E extends IDirectedEdge<N,E>>
Specified by:
iterator in interface java.util.Collection<E extends IDirectedEdge<N,E>>
Specified by:
iterator in interface java.util.Set<E extends IDirectedEdge<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 IDirectedNode<N,? extends IDirectedEdge<N,?>>,E extends IDirectedEdge<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 IDirectedNode<N,? extends IDirectedEdge<N,?>>,E extends IDirectedEdge<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 IDirectedNode<N,? extends IDirectedEdge<N,?>>,E extends IDirectedEdge<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 outNode,
                        N inNode)
Description copied from interface: IDirectedEdgeSet
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 IDirectedEdgeSet<N extends IDirectedNode<N,? extends IDirectedEdge<N,?>>,E extends IDirectedEdge<N,E>>
Specified by:
contains in interface IEdgeSet<N extends IDirectedNode<N,? extends IDirectedEdge<N,?>>,E extends IDirectedEdge<N,E>>
Parameters:
outNode - The node from which the edge is leading out from.
inNode - The node from which the edge is leading into.
Returns:
True if one or more edges has this connectivity, false otherwise.

get

public java.util.SortedSet<E> get(N outNode,
                                  N inNode)
Description copied from interface: IDirectedEdgeSet
Get the edges that match the given node connectivity. The connectivity is directed so to find an undirected edge the reciprocal node connectivity may need to be used.

Specified by:
get in interface IDirectedEdgeSet<N extends IDirectedNode<N,? extends IDirectedEdge<N,?>>,E extends IDirectedEdge<N,E>>
Specified by:
get in interface IEdgeSet<N extends IDirectedNode<N,? extends IDirectedEdge<N,?>>,E extends IDirectedEdge<N,E>>
Parameters:
outNode - The node that the edge is leading into. Cannot be null.
inNode - The node that the edge is leading out from. 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 IDirectedNode<N,? extends IDirectedEdge<N,?>>,E extends IDirectedEdge<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 IDirectedEdge<N,E>>
Specified by:
add in interface java.util.Set<E extends IDirectedEdge<N,E>>

size

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

addAll

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

clear

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

contains

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

containsAll

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

isEmpty

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

remove

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

removeAll

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

retainAll

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

toArray

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

toArray

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