PartitionsIterator.java :  » Math » algebra » ru » susu » algebra » partition » Java Open Source

Java Open Source » Math » algebra 
algebra » ru » susu » algebra » partition » PartitionsIterator.java
package ru.susu.algebra.partition;

import java.util.Iterator;

/**
 * @author akargapolov
 * @since: 09.03.2010
 */
public class PartitionsIterator implements Iterator<Partition>
{
  private Integer _number;
  private Integer _current;
  private Long _all;

  public PartitionsIterator(Integer number)
  {
    _number = number;
    _current = 0;
    _all = PartitionEnumerator.getPartitionsNumber(_number);
  }

  @Override
  public boolean hasNext()
  {
    return _current < _all;
  }

  @Override
  public Partition next()
  {
    return PartitionsFactory.createPartition(_current++, _number);
  }

  @Override
  public void remove()
  {
    throw new RuntimeException("I can't do it!!!");
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.