Package Torello.Java.ReadOnly
Interface ReadOnlySortedSet<E>
-
- Type Parameters:
E- the type of elements maintained by this set
- All Superinterfaces:
java.lang.Iterable<E>,ReadOnlyCollection<E>,ReadOnlySequencedCollection<E>,ReadOnlySequencedSet<E>,ReadOnlySet<E>
- All Known Subinterfaces:
ReadOnlyNavigableSet<E>
- All Known Implementing Classes:
ReadOnlyTreeSet
public interface ReadOnlySortedSet<E> extends ReadOnlySet<E>, ReadOnlySequencedSet<E>
This interface was originally copied fromGitHub's Open-JDKAccount. Though the original file has been modified, few changes have been applied to the Javadoc Commenting. Due to fact that that is a Javainterfacefile, there were few method bodies with Source-Code to begin with - meaning this is largely a copy of Method-Signatures and Java-Doc Comments.
Method and parameter names & types have not been modified whatsoever; but several methods had to be eliminated for not being Read-Only. This Source-File was copied from the original Open JDK-21 file of the same (or, rather, highly similar) Interface-Name. The original file may be viewed on theJDK-21 GitHubpublic (and, coincidentally, Read-Only) Source-Release archive for Java Packagejava.util.*
The Original'.java'Source-File's Header-Copyright Information is included here:File Copyright. Within that Copyright Notice, it is suggested that a copy of theGNU Public License V2also be included alongside.Immutable variant of Java Collections Framework interfacejava.util.SortedSet<E>. This interface contains all of the methods that the standard Java interface ReadOnlySortedSet contains - except those which would directly or indirectly modify / mutate the internal data-structure.
Hi-Lited Source-Code:- View Here: Torello/Java/ReadOnly/ReadOnlySortedSet.java
- Open New Browser-Tab: Torello/Java/ReadOnly/ReadOnlySortedSet.java
File Size: 11,018 Bytes Line Count: 247 '\n' Characters Found
-
-
Method Summary
Retrieve a Set Element Modifier and Type Method Efirst()Elast()Retrieve a Sub-Set as a ReadOnlySortedSet Modifier and Type Method ReadOnlySortedSet<E>headSet(E toElement)ReadOnlySortedSet<E>subSet(E fromElement, E toElement)ReadOnlySortedSet<E>tailSet(E fromElement)Retrieve this Set's Comparator Modifier and Type Method Comparator<? super E>comparator()Default Methods (Interface Methods with a Concrete, Default Implementation) Modifier and Type Method default EgetFirst()default EgetLast()default ReadOnlySortedSet<E>reversed()default Spliterator<E>spliterator()-
Methods inherited from interface Torello.Java.ReadOnly.ReadOnlyCollection
containsAND, containsAND, containsNAND, containsNAND, containsOR, containsOR, containsXOR, containsXOR, copyIntoCollection, parallelStream, stream, toArray
-
Methods inherited from interface Torello.Java.ReadOnly.ReadOnlySet
cloneToSet, contains, containsAll, equals, hashCode, isEmpty, iterator, size, toArray, toArray, wrapToImmutableSet
-
-
-
-
Method Detail
-
comparator
java.util.Comparator<? super E> comparator()
Returns the comparator used to order the elements in this set, ornullif this set uses the natural ordering of its elements.- Returns:
- the comparator used to order the elements in this set, or
nullif this set uses the natural ordering of its elements
-
subSet
ReadOnlySortedSet<E> subSet(E fromElement, E toElement)
Returns a view of the portion of this set whose elements range fromfromElement, inclusive, totoElement, exclusive. (IffromElementandtoElementare equal, the returned set is empty.) The returned set supports all optional set operations that this set supports.- Parameters:
fromElement- low endpoint (inclusive) of the returned settoElement- high endpoint (exclusive) of the returned set- Returns:
- a view of the portion of this set whose elements range from
fromElement, inclusive, totoElement, exclusive - Throws:
java.lang.ClassCastException- iffromElementandtoElementcannot be compared to one another using this set's comparator (or, if the set has no comparator, using natural ordering). Implementations may, but are not required to, throw this exception iffromElementortoElementcannot be compared to elements currently in the set.java.lang.NullPointerException- iffromElementortoElementis null and this set does not permit null elementsjava.lang.IllegalArgumentException- iffromElementis greater thantoElement; or if this set itself has a restricted range, andfromElementortoElementlies outside the bounds of the range
-
headSet
ReadOnlySortedSet<E> headSet(E toElement)
Returns a view of the portion of this set whose elements are strictly less thantoElement. The returned set supports all optional set operations that this set supports.- Parameters:
toElement- high endpoint (exclusive) of the returned set- Returns:
- a view of the portion of this set whose elements are strictly less than
toElement - Throws:
java.lang.ClassCastException- iftoElementis not compatible with this set's comparator (or, if the set has no comparator, iftoElementdoes not implementComparable). Implementations may, but are not required to, throw this exception iftoElementcannot be compared to elements currently in the set.java.lang.NullPointerException- iftoElementis null and this set does not permit null elementsjava.lang.IllegalArgumentException- if this set itself has a restricted range, andtoElementlies outside the bounds of the range
-
tailSet
ReadOnlySortedSet<E> tailSet(E fromElement)
Returns a view of the portion of this set whose elements are greater than or equal tofromElement. The returned set supports all optional set operations that this set supports.- Parameters:
fromElement- low endpoint (inclusive) of the returned set- Returns:
- a view of the portion of this set whose elements are greater than or equal to
fromElement - Throws:
java.lang.ClassCastException- iffromElementis not compatible with this set's comparator (or, if the set has no comparator, iffromElementdoes not implementComparable). Implementations may, but are not required to, throw this exception iffromElementcannot be compared to elements currently in the set.java.lang.NullPointerException- iffromElementis null and this set does not permit null elementsjava.lang.IllegalArgumentException- if this set itself has a restricted range, andfromElementlies outside the bounds of the range
-
first
-
last
-
spliterator
default java.util.Spliterator<E> spliterator()
Creates aSpliteratorover the elements in this sorted set.
TheSpliteratorreportsSpliterator.DISTINCT,Spliterator.SORTED}. Implementations should document the reporting of additional characteristic values.
The spliterator's comparator (seeSpliterator.getComparator()) must benullif the sorted set's comparator (seecomparator()) isnull. Otherwise, the spliterator's comparator must be the same as or impose the same total ordering as the sorted set's comparator.- Specified by:
spliteratorin interfacejava.lang.Iterable<E>- Specified by:
spliteratorin interfaceReadOnlyCollection<E>- Specified by:
spliteratorin interfaceReadOnlySet<E>- Returns:
- a
Spliteratorover the elements in this sorted set - Code:
- Exact Method Body:
// *** Java-HTML: Some Spliterators Code was copied into this package return new Iterator_Spliterator<E> (this, Spliterator.DISTINCT | Spliterator.SORTED | Spliterator.ORDERED) { @Override public Comparator<? super E> getComparator() { return ReadOnlySortedSet.this.comparator(); } };
-
getFirst
default E getFirst()
Gets the first element of this collection.- Specified by:
getFirstin interfaceReadOnlySequencedCollection<E>- Returns:
- the retrieved element
- Throws:
NoSuchElementException- Code:
- Exact Method Body:
return this.first();
-
getLast
default E getLast()
Gets the last element of this collection.- Specified by:
getLastin interfaceReadOnlySequencedCollection<E>- Returns:
- the retrieved element
- Throws:
NoSuchElementException- Code:
- Exact Method Body:
return this.last();
-
reversed
default ReadOnlySortedSet<E> reversed()
Returns a reverse-ordered view of this collection. The encounter order of elements in the returned view is the inverse of the encounter order of elements in this collection. The reverse ordering affects all order-sensitive operations, including those on the view collections of the returned view.- Specified by:
reversedin interfaceReadOnlySequencedCollection<E>- Specified by:
reversedin interfaceReadOnlySequencedSet<E>- Returns:
- a reverse-ordered view of this collection, as a
ReadOnlySortedSet - Code:
- Exact Method Body:
// *** Java-HTML: This is the use of the ReverseOrderedSortedSetView // This was copied out of "Package-Private" stuff for the JDK 21 // from the OpenJDK class on Git-Hub return JDKReverseOrderSortedSetView.of(this); // This is how it should work - but I went with the "Full Blow Diabolic Hack" // idea instead !! // throw new UnsupportedOperationException();
-
-