|
|
@@ -1,21 +1,9 @@
|
|
|
/*
|
|
|
- * @author Paolo Boldi
|
|
|
- * @author Sebastiano Vigna
|
|
|
- * @author Ranides Atterwim <contact@ranides.net>
|
|
|
- *
|
|
|
- * 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.
|
|
|
+ * @author Ranides Atterwim <ranides@gmail.com>
|
|
|
+ * @copyright Ranides Atterwim
|
|
|
+ * @license WTFPL
|
|
|
+ * @url http://ranides.net/projects/assira
|
|
|
*/
|
|
|
-
|
|
|
package net.ranides.assira.collection.sets;
|
|
|
|
|
|
import java.util.SortedSet;
|
|
|
@@ -23,50 +11,35 @@ import net.ranides.assira.collection.IntComparator;
|
|
|
import net.ranides.assira.collection.iterators.IntIterator;
|
|
|
|
|
|
/**
|
|
|
- * An abstract class providing basic methods for sorted sets implementing a
|
|
|
- * type-specific interface.
|
|
|
- * @todo (assira # 6) review
|
|
|
+ * An abstract base class for sorted sets of primitive int values.
|
|
|
+ * Designed to avoid autoboxing.
|
|
|
*/
|
|
|
public abstract class IntSortedSet extends IntSet implements SortedSet<Integer> {
|
|
|
|
|
|
protected IntSortedSet() {
|
|
|
+ // do nothing
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Delegates to the corresponding type-specific method.
|
|
|
- */
|
|
|
@Override
|
|
|
public IntSortedSet headSet(Integer toKey) {
|
|
|
return headSet(toKey.intValue());
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Delegates to the corresponding type-specific method.
|
|
|
- */
|
|
|
@Override
|
|
|
public IntSortedSet tailSet(Integer fromKey) {
|
|
|
return tailSet(fromKey.intValue());
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Delegates to the corresponding type-specific method.
|
|
|
- */
|
|
|
@Override
|
|
|
public IntSortedSet subSet(Integer fromKey, Integer toKey) {
|
|
|
return subSet(fromKey.intValue(), toKey.intValue());
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Delegates to the corresponding type-specific method.
|
|
|
- */
|
|
|
@Override
|
|
|
public Integer first() {
|
|
|
return firstInt();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Delegates to the corresponding type-specific method.
|
|
|
- */
|
|
|
@Override
|
|
|
public Integer last() {
|
|
|
return lastInt();
|
|
|
@@ -76,38 +49,21 @@ public abstract class IntSortedSet extends IntSet implements SortedSet<Integer>
|
|
|
public abstract IntIterator iterator();
|
|
|
|
|
|
/**
|
|
|
- * Returns a type-specific
|
|
|
- * {@link it.unimi.dsi.fastutil.BidirectionalIterator} on the elements in
|
|
|
- * this set, starting from a given element of the domain (optional
|
|
|
- * operation).
|
|
|
- *
|
|
|
- * <P>This method returns a type-specific bidirectional iterator with given
|
|
|
+ * <P>This method returns a iterator with given
|
|
|
* starting point. The starting point is any element comparable to the
|
|
|
* elements of this set (even if it does not actually belong to the set).
|
|
|
* The next element of the returned iterator is the least element of the set
|
|
|
* that is greater than the starting point (if there are no elements greater
|
|
|
- * than the starting point, {@link
|
|
|
- * it.unimi.dsi.fastutil.BidirectionalIterator#hasNext() hasNext()} will
|
|
|
- * return
|
|
|
- * <code>false</code>). The previous element of the returned iterator is the
|
|
|
- * greatest element of the set that is smaller than or equal to the starting
|
|
|
- * point (if there are no elements smaller than or equal to the starting
|
|
|
- * point, {@link it.unimi.dsi.fastutil.BidirectionalIterator#hasPrevious()
|
|
|
- * hasPrevious()} will return
|
|
|
- * <code>false</code>).
|
|
|
- *
|
|
|
- * <P>Note that passing the last element of the set as starting point and
|
|
|
- * calling
|
|
|
- * {@link it.unimi.dsi.fastutil.BidirectionalIterator#previous() previous()}
|
|
|
- * you can traverse the entire set in reverse order.
|
|
|
+ * than the starting point, {@link IntIterator#hasNext() hasNext()} will
|
|
|
+ * return <code>false</code>).
|
|
|
*
|
|
|
- * @param fromElement an element to start from.
|
|
|
- * @return a bidirectional iterator on the element in this set, starting at
|
|
|
+ * @param begin an element to start from.
|
|
|
+ * @return an iterator on the element in this set, starting at
|
|
|
* the given element.
|
|
|
* @throws UnsupportedOperationException if this set does not support
|
|
|
* iterators with a starting point.
|
|
|
*/
|
|
|
- public abstract IntIterator iterator(int fromElement);
|
|
|
+ public abstract IntIterator iterator(int begin);
|
|
|
|
|
|
/**
|
|
|
* Returns the comparator associated with this sorted set, or null if it
|
|
|
@@ -124,17 +80,17 @@ public abstract class IntSortedSet extends IntSet implements SortedSet<Integer>
|
|
|
/**
|
|
|
* @see SortedSet#subSet(Object,Object)
|
|
|
*/
|
|
|
- public abstract IntSortedSet subSet(int fromElement, int toElement);
|
|
|
+ public abstract IntSortedSet subSet(int begin, int end);
|
|
|
|
|
|
/**
|
|
|
* @see SortedSet#headSet(Object)
|
|
|
*/
|
|
|
- public abstract IntSortedSet headSet(int toElement);
|
|
|
+ public abstract IntSortedSet headSet(int begin);
|
|
|
|
|
|
/**
|
|
|
* @see SortedSet#tailSet(Object)
|
|
|
*/
|
|
|
- public abstract IntSortedSet tailSet(int fromElement);
|
|
|
+ public abstract IntSortedSet tailSet(int begin);
|
|
|
|
|
|
/**
|
|
|
* @see SortedSet#first()
|