// Path: src/main/java/org/dmfs/rfc5545/recurrenceset/AbstractRecurrenceAdapter.java
// interface InstanceIterator
// {
// 
//     /**
//      * Check if there is at least one more instance to iterate.
//      *
//      * @return <code>true</code> if the next call to {@link #next()} will return another instance, <code>false</code> otherwise.
//      */
//     abstract boolean hasNext();
// 
//     /**
//      * Get the next instance of this set. Do not call this if {@link #hasNext()} returns <code>false</code>.
//      *
//      * @return The time in milliseconds since the epoch of the next instance.
//      *
//      * @throws ArrayIndexOutOfBoundsException
//      *         if there are no more instances.
//      */
//     abstract long next();
// 
//     /**
//      * Skip all instances till <code>until</code>. If <code>until</code> is an instance itself it will be the next iterated instance. If the rule doesn't
//      * recur till that date the next call to {@link #hasNext()} will return <code>false</code>.
//      *
//      * @param until
//      *         A time stamp of the date to fast forward to.
//      */
//     abstract void fastForward(long until);
// 
// }


import org.dmfs.rfc5545.recurrenceset.AbstractRecurrenceAdapter.InstanceIterator;
import java.util.List;
import java.util.Locale;
/*
 * Copyright (C) 2013 Marten Gajda <marten@dmfs.org>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package org.dmfs.rfc5545.recurrenceset;




/**
 * An iterator for recurrence sets. It takes a number of {@link AbstractRecurrenceAdapter}s for instances and exceptions and iterates all resulting instances
 * (i.e. only the instances, not the exceptions). <p> This class doesn't implement the {@link InstanceIterator} interface for one reasons: </p> <ul> <li>An
 * {@link InstanceIterator} always returns an {@link Object}, so instead of a primitive <code>long</code> we would have to return a {@link Long}. That is an
 * additional object which doesn't have any advantage.</li> </ul>
 *
 * @author Marten Gajda
 */
public class RecurrenceSetIterator
{
    /**
     * Throw if we skipped this many instances in a line, because they were exceptions.
     */
    private final static int MAX_SKIPPED_INSTANCES = 1000;

// Path: src/main/java/org/dmfs/rfc5545/recurrenceset/AbstractRecurrenceAdapter.java
// interface InstanceIterator
// {
// 
//     /**
//      * Check if there is at least one more instance to iterate.
//      *
//      * @return <code>true</code> if the next call to {@link #next()} will return another instance, <code>false</code> otherwise.
//      */
//     abstract boolean hasNext();
// 
//     /**
//      * Get the next instance of this set. Do not call this if {@link #hasNext()} returns <code>false</code>.
//      *
//      * @return The time in milliseconds since the epoch of the next instance.
//      *
//      * @throws ArrayIndexOutOfBoundsException
//      *         if there are no more instances.
//      */
//     abstract long next();
// 
//     /**
//      * Skip all instances till <code>until</code>. If <code>until</code> is an instance itself it will be the next iterated instance. If the rule doesn't
//      * recur till that date the next call to {@link #hasNext()} will return <code>false</code>.
//      *
//      * @param until
//      *         A time stamp of the date to fast forward to.
//      */
//     abstract void fastForward(long until);
// 
// }


// Path: src/main/java/org/dmfs/rfc5545/recurrenceset/RecurrenceSetIterator.java
import org.dmfs.rfc5545.recurrenceset.AbstractRecurrenceAdapter.InstanceIterator;
import java.util.List;
import java.util.Locale;

/*
 * Copyright (C) 2013 Marten Gajda <marten@dmfs.org>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package org.dmfs.rfc5545.recurrenceset;




/**
 * An iterator for recurrence sets. It takes a number of {@link AbstractRecurrenceAdapter}s for instances and exceptions and iterates all resulting instances
 * (i.e. only the instances, not the exceptions). <p> This class doesn't implement the {@link InstanceIterator} interface for one reasons: </p> <ul> <li>An
 * {@link InstanceIterator} always returns an {@link Object}, so instead of a primitive <code>long</code> we would have to return a {@link Long}. That is an
 * additional object which doesn't have any advantage.</li> </ul>
 *
 * @author Marten Gajda
 */
public class RecurrenceSetIterator
{
    /**
     * Throw if we skipped this many instances in a line, because they were exceptions.
     */
    private final static int MAX_SKIPPED_INSTANCES = 1000;

    private final InstanceIterator mInstances;