Package edu.jas.util
Class CartesianProductLongIterator
- java.lang.Object
-
- edu.jas.util.CartesianProductLongIterator
-
- All Implemented Interfaces:
java.util.Iterator<java.util.List<java.lang.Long>>
class CartesianProductLongIterator extends java.lang.Object implements java.util.Iterator<java.util.List<java.lang.Long>>
Cartesian product iterator for Longs. Similar to CartesianProductIterator but returns only tuples of given total degree.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.List<LongIterator>
compit
(package private) java.util.List<LongIterable>
comps
data structure.(package private) java.util.List<java.lang.Long>
current
(package private) boolean
empty
long
upperBound
-
Constructor Summary
Constructors Constructor Description CartesianProductLongIterator(java.util.List<LongIterable> comps, long ub)
CartesianProduct iterator constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasNext()
Test for availability of a next tuple.java.util.List<java.lang.Long>
next()
Get next tuple.void
remove()
Remove a tuple if allowed.long
totalDegree(java.util.List<java.lang.Long> e)
Total degree of a tuple.
-
-
-
Field Detail
-
comps
final java.util.List<LongIterable> comps
data structure.
-
compit
final java.util.List<LongIterator> compit
-
current
java.util.List<java.lang.Long> current
-
empty
boolean empty
-
upperBound
public final long upperBound
-
-
Constructor Detail
-
CartesianProductLongIterator
public CartesianProductLongIterator(java.util.List<LongIterable> comps, long ub)
CartesianProduct iterator constructor.- Parameters:
comps
- components of the Cartesian product.ub
- an upper bound for the total degree of the elements.
-
-
Method Detail
-
hasNext
public boolean hasNext()
Test for availability of a next tuple.- Specified by:
hasNext
in interfacejava.util.Iterator<java.util.List<java.lang.Long>>
- Returns:
- true if the iteration has more tuples, else false.
-
next
public java.util.List<java.lang.Long> next()
Get next tuple.- Specified by:
next
in interfacejava.util.Iterator<java.util.List<java.lang.Long>>
- Returns:
- next tuple.
-
totalDegree
public long totalDegree(java.util.List<java.lang.Long> e)
Total degree of a tuple.- Parameters:
e
- list of Longs.- Returns:
- sum of all elements in e.
-
remove
public void remove()
Remove a tuple if allowed.- Specified by:
remove
in interfacejava.util.Iterator<java.util.List<java.lang.Long>>
-
-