



org.eclipse.jst.jsf.common.sets
Class NodeSet
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet
org.eclipse.jst.jsf.common.sets.NodeSet

All Implemented Interfaces:
 java.lang.Iterable, java.util.Collection, java.util.Set,
AxiomaticSet

public class NodeSet
 extends java.util.AbstractSet
 implements
AxiomaticSet
A set backed by a W3C NodeList so as to avoid copying. Note that operations
that return new sets still invoke a copy. Also, membership operations
require O(n) time. This should generally used for sets that are assumed to be
small where O(n) search time will be small compared to doing a full copy.
This set is immutable (mutation methods throw exceptions)
Provisional API  subject to change
Constructor Summary

NodeSet
(org.w3c.dom.NodeList data)

Methods inherited from class java.util.AbstractSet

equals, hashCode, removeAll

Methods inherited from class java.util.AbstractCollection

add, addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString

Methods inherited from class java.lang.Object

getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.Set

add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray

NodeSet
public NodeSet(org.w3c.dom.NodeList data)

Parameters:

data   wrap the actual data source
iterator
public java.util.Iterator iterator()


Specified by:

iterator in interface java.lang.Iterable

Specified by:

iterator in interface java.util.Collection

Specified by:

iterator in interface java.util.Set

Specified by:

iterator in class java.util.AbstractCollection

size
public int size()


Specified by:

size in interface java.util.Collection

Specified by:

size in interface java.util.Set

Specified by:

size in class java.util.AbstractCollection

intersect
public
AxiomaticSet intersect(
AxiomaticSet set)


Specified by:

intersect
in interface
AxiomaticSet


Returns:
 the axiomatic intersection of this set with set
isEquivalent
public boolean isEquivalent(
AxiomaticSet toSet)

Description copied from interface:
AxiomaticSet
 Implementations should aim to provide O(mn) time cost
where n is the number of elements in this set and
m is the cost to check membership of an element in this
set in toSet. When a set is itself a member of a set,
the implementation must call isEquivalent on those subsets
recursively.


Specified by:

isEquivalent
in interface
AxiomaticSet


Returns:
 true iff this set is equivalent toSet. Note
that extensionality holds that two sets are equivalent
if and only if they contain exactly the same elements.
union
public
AxiomaticSet union(
AxiomaticSet set)


Specified by:

union
in interface
AxiomaticSet


Returns:
 the axiomatic union of this set with set
isDisjoint
public boolean isDisjoint(
AxiomaticSet set)


Specified by:

isDisjoint
in interface
AxiomaticSet


Returns:
 convenience method that must be equivalent to
(this.intersect(set).isEmpty())
getFirstElement
public java.lang.Object getFirstElement()


Specified by:

getFirstElement
in interface
AxiomaticSet


Returns:
 the first element in the set. There is no guarantee which element
will be chosen, but the call should always return the same element of the set
for multiple invocations on the same set. Generally this is a convience method
for when the set only contains one element.
subtract
public
AxiomaticSet subtract(
AxiomaticSet set)

Description copied from interface:
AxiomaticSet
 The set constructed by the removing the intersection
of this with set from this. The set will contain all
elements in this that are not in set.
Eqivalence: this  set


Specified by:

subtract
in interface
AxiomaticSet


Returns:
 the relative complement or theoretic difference of
set from this


