org.jgrapht.experimental.permutation
Class CollectionPermutationIter<E>

java.lang.Object
  extended by org.jgrapht.experimental.permutation.CollectionPermutationIter<E>

public class CollectionPermutationIter<E>
extends Object

Given a container with elements (Collection,Enumeration,array) defines a permutation iterator which returns, on each iteration, a differnt permutation of the source container. You may choose a different container type(Collection/Array/etc) for each next call. It will continue as if they were the same iterator.

Since:
May 20, 2005
Author:
Assaf

Constructor Summary
CollectionPermutationIter(List<E> objectsArray)
          Uses a permArray like [1,1,1,2] where some of the permutations are not relevant.
CollectionPermutationIter(List<E> objectsArray, ArrayPermutationsIter permuter)
           
CollectionPermutationIter(Set<E> objectsSet)
          Note: the Set interface does not guarantee iteration order.
 
Method Summary
 int[] getCurrentPermutationArray()
           
 List<E> getNextArray()
          On first call, returns the source as an array; on any other call thereafter, a new permutation
 Set<E> getNextSet()
          Wrap result to a Set.
 boolean hasNext()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CollectionPermutationIter

public CollectionPermutationIter(Set<E> objectsSet)
Note: the Set interface does not guarantee iteration order. This method iterates on the set to get the initial order and after that the data will be saved internally in another (ordered) container. So, remeber that the Initial order can be different from the objectSet.toString() method. If you want it to be the same, use a LinkedHashSet , or use the array constructor.

Parameters:
objectsSet -

CollectionPermutationIter

public CollectionPermutationIter(List<E> objectsArray)
Uses a permArray like [1,1,1,2] where some of the permutations are not relevant. Here there will be 4 permutations (only the '2' position is important)

Parameters:
objectsArray -

CollectionPermutationIter

public CollectionPermutationIter(List<E> objectsArray,
                                 ArrayPermutationsIter permuter)
Method Detail

hasNext

public boolean hasNext()

getNextArray

public List<E> getNextArray()
On first call, returns the source as an array; on any other call thereafter, a new permutation

Returns:
null if we overflowed! the array otherwise

getNextSet

public Set<E> getNextSet()
Wrap result to a Set.

Returns:
null if we overflowed! the set otherwise

getCurrentPermutationArray

public int[] getCurrentPermutationArray()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All rights reserved.