Package it.unimi.dsi.fastutil.objects
Class ObjectSortedSets
- java.lang.Object
-
- it.unimi.dsi.fastutil.objects.ObjectSortedSets
-
public final class ObjectSortedSets extends java.lang.Object
A class providing static methods and objects that do useful things with type-specific sorted sets.- See Also:
Collections
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ObjectSortedSets.EmptySet<K>
An immutable class representing the empty sorted set and implementing a type-specific set interface.static class
ObjectSortedSets.Singleton<K>
A class representing a singleton sorted set.static class
ObjectSortedSets.SynchronizedSortedSet<K>
A synchronized wrapper class for sorted sets.static class
ObjectSortedSets.UnmodifiableSortedSet<K>
An unmodifiable wrapper class for sorted sets.
-
Field Summary
Fields Modifier and Type Field Description static ObjectSortedSets.EmptySet
EMPTY_SET
An empty sorted set (immutable).
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <K> ObjectSet<K>
emptySet()
Returns an empty sorted set (immutable).static <K> ObjectSortedSet<K>
singleton(K element)
Returns a type-specific immutable sorted set containing only the specified element.static <K> ObjectSortedSet<K>
singleton(K element, java.util.Comparator<? super K> comparator)
Returns a type-specific immutable sorted set containing only the specified element, and using a specified comparator.static <K> ObjectSortedSet<K>
synchronize(ObjectSortedSet<K> s)
Returns a synchronized type-specific sorted set backed by the given type-specific sorted set.static <K> ObjectSortedSet<K>
synchronize(ObjectSortedSet<K> s, java.lang.Object sync)
Returns a synchronized type-specific sorted set backed by the given type-specific sorted set, using an assigned object to synchronize.static <K> ObjectSortedSet<K>
unmodifiable(ObjectSortedSet<K> s)
Returns an unmodifiable type-specific sorted set backed by the given type-specific sorted set.
-
-
-
Field Detail
-
EMPTY_SET
public static final ObjectSortedSets.EmptySet EMPTY_SET
An empty sorted set (immutable). It is serializable and cloneable.
-
-
Method Detail
-
emptySet
public static <K> ObjectSet<K> emptySet()
Returns an empty sorted set (immutable). It is serializable and cloneable.This method provides a typesafe access to
EMPTY_SET
.- Returns:
- an empty sorted set (immutable).
-
singleton
public static <K> ObjectSortedSet<K> singleton(K element)
Returns a type-specific immutable sorted set containing only the specified element. The returned sorted set is serializable and cloneable.- Parameters:
element
- the only element of the returned sorted set.- Returns:
- a type-specific immutable sorted set containing just
element
.
-
singleton
public static <K> ObjectSortedSet<K> singleton(K element, java.util.Comparator<? super K> comparator)
Returns a type-specific immutable sorted set containing only the specified element, and using a specified comparator. The returned sorted set is serializable and cloneable.- Parameters:
element
- the only element of the returned sorted set.comparator
- the comparator to use in the returned sorted set.- Returns:
- a type-specific immutable sorted set containing just
element
.
-
synchronize
public static <K> ObjectSortedSet<K> synchronize(ObjectSortedSet<K> s)
Returns a synchronized type-specific sorted set backed by the given type-specific sorted set.- Parameters:
s
- the sorted set to be wrapped in a synchronized sorted set.- Returns:
- a synchronized view of the specified sorted set.
- See Also:
Collections.synchronizedSortedSet(SortedSet)
-
synchronize
public static <K> ObjectSortedSet<K> synchronize(ObjectSortedSet<K> s, java.lang.Object sync)
Returns a synchronized type-specific sorted set backed by the given type-specific sorted set, using an assigned object to synchronize.- Parameters:
s
- the sorted set to be wrapped in a synchronized sorted set.sync
- an object that will be used to synchronize the access to the sorted set.- Returns:
- a synchronized view of the specified sorted set.
- See Also:
Collections.synchronizedSortedSet(SortedSet)
-
unmodifiable
public static <K> ObjectSortedSet<K> unmodifiable(ObjectSortedSet<K> s)
Returns an unmodifiable type-specific sorted set backed by the given type-specific sorted set.- Parameters:
s
- the sorted set to be wrapped in an unmodifiable sorted set.- Returns:
- an unmodifiable view of the specified sorted set.
- See Also:
Collections.unmodifiableSortedSet(SortedSet)
-
-