addAll
Adds all of the elements in the specified collection to this set.
- Specified by:
-
addAll in interface Collection<E>
- Specified by:
-
addAll in interface Set<E>
- Overrides:
-
addAll in class AbstractCollection<E>
- Parameters:
-
c - collection containing elements to be added to this set
- Returns:
-
true if this set changed as a result of the call
- Throws:
-
ClassCastException - if the elements provided cannot be compared with the elements currently in the set
-
NullPointerException - if the specified collection is null or if any element is null and this set uses natural ordering, or its comparator does not permit null elements
- See Also:
-
AbstractCollection.add(Object)
subSet
public NavigableSet<E> subSet?( E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
Returns a view of the portion of this set whose elements range from fromElement to toElement . If fromElement and toElement are equal, the returned set is empty unless fromInclusive and toInclusive are both true. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports. The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
- Specified by:
-
subSet in interface NavigableSet<E>
- Parameters:
-
fromElement - low endpoint of the returned set
-
fromInclusive - true if the low endpoint is to be included in the returned view
-
toElement - high endpoint of the returned set
-
toInclusive - true if the high endpoint is to be included in the returned view
- Returns:
- a view of the portion of this set whose elements range from
fromElement , inclusive, to toElement , exclusive
- Throws:
-
ClassCastException - if fromElement and toElement cannot 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 if fromElement or toElement cannot be compared to elements currently in the set.
-
NullPointerException - if fromElement or toElement is null and this set uses natural ordering, or its comparator does not permit null elements
-
IllegalArgumentException - if fromElement is greater than toElement ; or if this set itself has a restricted range, and fromElement or toElement lies outside the bounds of the range.
- Since:
- 1.6
headSet
Returns a view of the portion of this set whose elements are less than (or equal to, if inclusive is true) toElement . The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports. The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
- Specified by:
-
headSet in interface NavigableSet<E>
- Parameters:
-
toElement - high endpoint of the returned set
-
inclusive - true if the high endpoint is to be included in the returned view
- Returns:
- a view of the portion of this set whose elements are less than (or equal to, if
inclusive is true) toElement
- Throws:
-
ClassCastException - if toElement is not compatible with this set's comparator (or, if the set has no comparator, if toElement does not implement Comparable ). Implementations may, but are not required to, throw this exception if toElement cannot be compared to elements currently in the set.
-
NullPointerException - if toElement is null and this set uses natural ordering, or its comparator does not permit null elements
-
IllegalArgumentException - if this set itself has a restricted range, and toElement lies outside the bounds of the range
- Since:
- 1.6
tailSet
Returns a view of the portion of this set whose elements are greater than (or equal to, if inclusive is true) fromElement . The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports. The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
- Specified by:
-
tailSet in interface NavigableSet<E>
- Parameters:
-
fromElement - low endpoint of the returned set
-
inclusive - true if the low endpoint is to be included in the returned view
- Returns:
- a view of the portion of this set whose elements are greater than or equal to
fromElement
- Throws:
-
ClassCastException - if fromElement is not compatible with this set's comparator (or, if the set has no comparator, if fromElement does not implement Comparable ). Implementations may, but are not required to, throw this exception if fromElement cannot be compared to elements currently in the set.
-
NullPointerException - if fromElement is null and this set uses natural ordering, or its comparator does not permit null elements
-
IllegalArgumentException - if this set itself has a restricted range, and fromElement lies outside the bounds of the range
- Since:
- 1.6
subSet
Returns a view of the portion of this set whose elements range from fromElement , inclusive, to toElement , exclusive. (If fromElement and toElement are equal, the returned set is empty.) The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports. The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
Equivalent to subSet(fromElement, true, toElement, false) .
- Specified by:
-
subSet in interface NavigableSet<E>
- Specified by:
-
subSet in interface SortedSet<E>
- Parameters:
-
fromElement - low endpoint (inclusive) of the returned set
-
toElement - high endpoint (exclusive) of the returned set
- Returns:
- a view of the portion of this set whose elements range from
fromElement , inclusive, to toElement , exclusive
- Throws:
-
ClassCastException - if fromElement and toElement cannot 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 if fromElement or toElement cannot be compared to elements currently in the set.
-
NullPointerException - if fromElement or toElement is null and this set uses natural ordering, or its comparator does not permit null elements
-
IllegalArgumentException - if fromElement is greater than toElement ; or if this set itself has a restricted range, and fromElement or toElement lies outside the bounds of the range
headSet
Returns a view of the portion of this set whose elements are strictly less than toElement . The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports. The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
Equivalent to headSet(toElement, false) .
- Specified by:
-
headSet in interface NavigableSet<E>
- Specified by:
-
headSet in interface SortedSet<E>
- 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:
-
ClassCastException - if toElement is not compatible with this set's comparator (or, if the set has no comparator, if toElement does not implement Comparable ). Implementations may, but are not required to, throw this exception if toElement cannot be compared to elements currently in the set.
-
NullPointerException - if toElement is null and this set uses natural ordering, or its comparator does not permit null elements
-
IllegalArgumentException - if this set itself has a restricted range, and toElement lies outside the bounds of the range
tailSet
Returns a view of the portion of this set whose elements are greater than or equal to fromElement . The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports. The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
Equivalent to tailSet(fromElement, true) .
- Specified by:
-
tailSet in interface NavigableSet<E>
- Specified by:
-
tailSet in interface SortedSet<E>
- 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:
-
ClassCastException - if fromElement is not compatible with this set's comparator (or, if the set has no comparator, if fromElement does not implement Comparable ). Implementations may, but are not required to, throw this exception if fromElement cannot be compared to elements currently in the set.
-
NullPointerException - if fromElement is null and this set uses natural ordering, or its comparator does not permit null elements
-
IllegalArgumentException - if this set itself has a restricted range, and fromElement lies outside the bounds of the range
|
|