Package overit.geocall.util
Class IntegerSet
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Integer>,Collection<Integer>,Iterator,NavigableSet<Integer>,SequencedCollection<Integer>,SequencedSet<Integer>,Set<Integer>,SortedSet<Integer>
This class extends
TreeSet and implements a navigable set of Integer elements.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty IntegerSet, sorted according to the natural ordering of its elements.IntegerSet(Integer... ii) Creates a new IntegerSet and fills it with the Integer values passed as parameters.IntegerSet(String s) Creates a new IntegerSet starting from the values contained in the string.IntegerSet(String s, char delim, char rangedelim) Creates a new IntegerSet starting from the values contained in the string.Creates a new IntegerSet and fills it with all the elements of theCollectionpassed as parameter; the elements in the collection must be of type Integer.IntegerSet(Comparator<Long> c) -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasNext()Checks if the intervals Iterator (seeintervalsIterator()) has a next elementsReturns an Iterator over the intervals (ranges) defined for the IntegerSetnext()Returns the next element of the intervals Iterator (seeintervalsIterator())voidremove()Empty methodprotected voidscanNext()Returns a string version of the IntegerSet in which the values are expressed in range form.toIntervalsString(char delim, char rangedelim) Returns a string version of the IntegerSet in which the values are expressed in range form.toString()Returns the string version of the IntegerSet, i.e. a string in which every value is separated from the next by the comma (,) character.toString(char delim) Returns the string version of the IntegerSet, i.e. a string in which every value is separated from the next by the delimiter character passed as parameterMethods inherited from class java.util.TreeSet
add, addAll, addFirst, addLast, ceiling, clear, clone, comparator, contains, descendingIterator, descendingSet, first, floor, headSet, headSet, higher, isEmpty, iterator, last, lower, pollFirst, pollLast, remove, size, spliterator, subSet, subSet, tailSet, tailSetMethods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArrayMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Iterator
forEachRemainingMethods inherited from interface java.util.NavigableSet
removeFirst, removeLast, reversed
-
Constructor Details
-
IntegerSet
-
IntegerSet
Creates a new IntegerSet and fills it with the Integer values passed as parameters. The IntegerSet is sorted according to the natural ordering of its elements.- Parameters:
ii- A variable number of Integer values that will fill the IntegerSet
-
IntegerSet
Creates a new IntegerSet and fills it with all the elements of theCollectionpassed as parameter; the elements in the collection must be of type Integer. The IntegerSet is sorted according to the natural ordering of its elements.- Parameters:
c- The Collection of Integer values that will fill the IntegerSet
-
IntegerSet
public IntegerSet()Creates a new empty IntegerSet, sorted according to the natural ordering of its elements. -
IntegerSet
Creates a new IntegerSet starting from the values contained in the string. Each value must be separated from the next by the comma (,). It is possible to indicate ranges of values by separating the start and end of the range using the minus character (-); the values between the beginning and the end of the range will all be included in the IntegerSet.
The IntegerSet is sorted according to the natural ordering of its elements.- Parameters:
s- The string that contains the values that will fill the IntegerSet
-
IntegerSet
Creates a new IntegerSet starting from the values contained in the string. Each value must be separated from the next by the delimiter character passed as second parameter. It is possible to indicate ranges of values by separating the start and end of the range using the range delimiter character passed as last parameter; the values between the beginning and the end of the range will all be included in the IntegerSet.
The IntegerSet is sorted according to the natural ordering of its elements.- Parameters:
s- The string that contains the values that will fill the IntegerSetdelim- The character that defines the values separatorrangedelim- The character that defines the range separator
-
-
Method Details
-
toString
Returns the string version of the IntegerSet, i.e. a string in which every value is separated from the next by the comma (,) character.- Overrides:
toStringin classAbstractCollection<Integer>- Returns:
- The string that represents the IntegerSet
-
toString
Returns the string version of the IntegerSet, i.e. a string in which every value is separated from the next by the delimiter character passed as parameter- Parameters:
delim- The character used to separate each value- Returns:
- The string that represents the IntegerSet
-
scanNext
protected void scanNext() -
intervalsIterator
Returns an Iterator over the intervals (ranges) defined for the IntegerSet- Returns:
- The Iterator in which every element is a values interval
-
hasNext
public boolean hasNext()Checks if the intervals Iterator (seeintervalsIterator()) has a next elements -
next
Returns the next element of the intervals Iterator (seeintervalsIterator()) -
remove
public void remove()Empty method -
toIntervalsString
Returns a string version of the IntegerSet in which the values are expressed in range form. Each range is indicated by the initial and the final value, separated by the minus sign (-), and each range is separated by the next one with the comma (,).- Returns:
- The string that represents the range version of the IntegerSet values
-
toIntervalsString
Returns a string version of the IntegerSet in which the values are expressed in range form. Each range is indicated by the initial and the final value, separated by the range delimiter character passed as second parameter. Each range is separated by the next one with the delimiter character, passed es first parameter.- Parameters:
delim- The character used to separate each rangerangedelim- The character that defines the range separator- Returns:
- The string that represents the range version of the IntegerSet values
-