Package it.unimi.dsi.fastutil.ints
Class Int2ObjectFunctions
java.lang.Object
it.unimi.dsi.fastutil.ints.Int2ObjectFunctions
public final class Int2ObjectFunctions
extends java.lang.Object
A class providing static methods and objects that do useful things with type-specific functions.
- See Also:
Function,Collections
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classInt2ObjectFunctions.EmptyFunction<V>An immutable class representing an empty type-specific function.static classInt2ObjectFunctions.PrimitiveFunction<V>An adapter for mapping generic total functions to partial primitive functions.static classInt2ObjectFunctions.Singleton<V>An immutable class representing a type-specific singleton function.static classInt2ObjectFunctions.SynchronizedFunction<V>A synchronized wrapper class for functions.static classInt2ObjectFunctions.UnmodifiableFunction<V>An unmodifiable wrapper class for functions. -
Field Summary
Fields Modifier and Type Field Description static Int2ObjectFunctions.EmptyFunctionEMPTY_FUNCTIONAn empty type-specific function (immutable). -
Method Summary
Modifier and Type Method Description static <V> Int2ObjectFunction<V>primitive(java.util.function.Function<? super java.lang.Integer,? extends V> f)Returns a (partial) type-specific function based on the given total generic function.static <V> Int2ObjectFunction<V>singleton(int key, V value)Returns a type-specific immutable function containing only the specified pair.static <V> Int2ObjectFunction<V>singleton(java.lang.Integer key, V value)Returns a type-specific immutable function containing only the specified pair.static <V> Int2ObjectFunction<V>synchronize(Int2ObjectFunction<V> f)Returns a synchronized type-specific function backed by the given type-specific function.static <V> Int2ObjectFunction<V>synchronize(Int2ObjectFunction<V> f, java.lang.Object sync)Returns a synchronized type-specific function backed by the given type-specific function, using an assigned object to synchronize.static <V> Int2ObjectFunction<V>unmodifiable(Int2ObjectFunction<? extends V> f)Returns an unmodifiable type-specific function backed by the given type-specific function.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
EMPTY_FUNCTION
An empty type-specific function (immutable). It is serializable and cloneable.
-
-
Method Details
-
singleton
Returns a type-specific immutable function containing only the specified pair. The returned function is serializable and cloneable.Note that albeit the returned function is immutable, its default return value may be changed.
- Parameters:
key- the only key of the returned function.value- the only value of the returned function.- Returns:
- a type-specific immutable function containing just the pair
<key,value>.
-
singleton
Returns a type-specific immutable function containing only the specified pair. The returned function is serializable and cloneable.Note that albeit the returned function is immutable, its default return value may be changed.
- Parameters:
key- the only key of the returned function.value- the only value of the returned function.- Returns:
- a type-specific immutable function containing just the pair
<key,value>.
-
synchronize
Returns a synchronized type-specific function backed by the given type-specific function.- Parameters:
f- the function to be wrapped in a synchronized function.- Returns:
- a synchronized view of the specified function.
- See Also:
Collections.synchronizedMap(java.util.Map)
-
synchronize
public static <V> Int2ObjectFunction<V> synchronize(Int2ObjectFunction<V> f, java.lang.Object sync)Returns a synchronized type-specific function backed by the given type-specific function, using an assigned object to synchronize.- Parameters:
f- the function to be wrapped in a synchronized function.sync- an object that will be used to synchronize the access to the function.- Returns:
- a synchronized view of the specified function.
- See Also:
Collections.synchronizedMap(java.util.Map)
-
unmodifiable
Returns an unmodifiable type-specific function backed by the given type-specific function.- Parameters:
f- the function to be wrapped in an unmodifiable function.- Returns:
- an unmodifiable view of the specified function.
- See Also:
Collections.unmodifiableMap(java.util.Map)
-
primitive
public static <V> Int2ObjectFunction<V> primitive(java.util.function.Function<? super java.lang.Integer,? extends V> f)Returns a (partial) type-specific function based on the given total generic function.The returned function contains all keys which are not mapped to
null. If the function already is a primitive function, it is returned without changes.Warning: If the given function is a “widened” primitive function (e.g. an
Int2IntFunctiongiven toShort2ShortFunctions), it still is wrapped into a proxy, decreasing performance.- Parameters:
f- the function to be converted to a type-specific function.- Returns:
- a primitive view of the specified function.
- Throws:
java.lang.NullPointerException- iffis null.- Since:
- 8.1.0
- See Also:
Int2ObjectFunctions.PrimitiveFunction
-