Package org.orekit.utils
Class DataDictionary
- java.lang.Object
-
- org.orekit.utils.DataDictionary
-
- All Implemented Interfaces:
Serializable
public class DataDictionary extends Object implements Serializable
String → Object mapping, for small number of keys.This class is a low overhead for a very small number of keys. It is based on simple array and string comparison. It plays the same role a
Map<String, Object>but with reduced features and not intended for large number of keys. For such needs the regularMap<String, Object>should be preferred.- Since:
- 13.0
- Author:
- Anne-Laure Lugan
- See Also:
DoubleArrayDictionary, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDataDictionary.EntryEntry in a dictionary.
-
Constructor Summary
Constructors Constructor Description DataDictionary()Constructor withdefault initial capacity.DataDictionary(int initialCapacity)Constructor with specified capacity.DataDictionary(DataDictionary dictionary)Constructor from another dictionary.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Remove all entries.Objectget(String key)Get the value corresponding to a key.List<DataDictionary.Entry>getData()Get an unmodifiable view of the dictionary entries.DataDictionary.EntrygetEntry(String key)Get a complete entry.voidput(String key, Object value)Add an entry.voidputAll(DataDictionary dictionary)Put all the entries from another dictionary.voidputAllDoubles(Map<String,double[]> map)Put all the double[] entries from the map in the dictionary.booleanremove(String key)Remove an entry.intsize()Get the number of dictionary entries.DoubleArrayDictionarytoDoubleDictionary()Creates a double values dictionary.Map<String,Object>toMap()Create a map from the instance.StringtoString()Get a string representation of the dictionary.static StringtoString(Map<String,Object> values)Get a string representation of the dictionary.
-
-
-
Constructor Detail
-
DataDictionary
public DataDictionary()
Constructor withdefault initial capacity.
-
DataDictionary
public DataDictionary(int initialCapacity)
Constructor with specified capacity.- Parameters:
initialCapacity- initial capacity
-
DataDictionary
public DataDictionary(DataDictionary dictionary)
Constructor from another dictionary.- Parameters:
dictionary- dictionary to use for initializing entries
-
-
Method Detail
-
toDoubleDictionary
public DoubleArrayDictionary toDoubleDictionary()
Creates a double values dictionary.Creates a DoubleArrayDictionary with all double[] values contained in the instance.
- Returns:
- a double values dictionary
-
getData
public List<DataDictionary.Entry> getData()
Get an unmodifiable view of the dictionary entries.- Returns:
- unmodifiable view of the dictionary entries
-
size
public int size()
Get the number of dictionary entries.- Returns:
- number of dictionary entries
-
toMap
public Map<String,Object> toMap()
Create a map from the instance.The map contains a copy of the instance data
- Returns:
- copy of the dictionary, as an independent map
-
clear
public void clear()
Remove all entries.
-
put
public void put(String key, Object value)
Add an entry.If an entry with the same key already exists, it will be removed first.
The new entry is always put at the end.
- Parameters:
key- entry keyvalue- entry value
-
putAllDoubles
public void putAllDoubles(Map<String,double[]> map)
Put all the double[] entries from the map in the dictionary.- Parameters:
map- map to copy into the instance
-
putAll
public void putAll(DataDictionary dictionary)
Put all the entries from another dictionary.- Parameters:
dictionary- dictionary to copy into the instance
-
get
public Object get(String key)
Get the value corresponding to a key.- Parameters:
key- entry key- Returns:
- copy of the value corresponding to the key or null if key not present
-
getEntry
public DataDictionary.Entry getEntry(String key)
Get a complete entry.- Parameters:
key- entry key- Returns:
- entry with key if it exists, null otherwise
-
remove
public boolean remove(String key)
Remove an entry.- Parameters:
key- key of the entry to remove- Returns:
- true if an entry has been removed, false if the key was not present
-
toString
public static String toString(Map<String,Object> values)
Get a string representation of the dictionary.This string representation is intended for improving displays in debuggers only.
- Parameters:
values- dictionary- Returns:
- string representation of the dictionary
-
-