Package org.orekit.utils
Class FieldDataDictionary<T extends CalculusFieldElement<T>>
- java.lang.Object
-
- org.orekit.utils.FieldDataDictionary<T>
-
public class FieldDataDictionary<T extends CalculusFieldElement<T>> extends Object
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:
- Bryan Cazabonne
- See Also:
FieldArrayDictionary
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
FieldDataDictionary.Entry
Entry in a dictionary.
-
Constructor Summary
Constructors Constructor Description FieldDataDictionary(Field<T> field)
Constructor withdefault initial capacity
.FieldDataDictionary(Field<T> field, int initialCapacity)
Constructor with specified capacity.FieldDataDictionary(Field<T> field, Map<String,Object> map)
Constructor from a map.FieldDataDictionary(FieldDataDictionary<T> dictionary)
Constructor from another dictionary.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Remove all entries.Object
get(String key)
Get the value corresponding to a key.List<FieldDataDictionary.Entry>
getData()
Get an unmodifiable view of the dictionary entries.FieldDataDictionary.Entry
getEntry(String key)
Get a complete entry.Field<T>
getField()
Get the field to which elements belong.void
put(String key, Object value)
Add an entry.void
putAll(Map<String,Object> map)
Put all the entries from the map in the dictionary.void
putAll(FieldDataDictionary<T> dictionary)
Put all the entries from another dictionary.void
putAllFields(Map<String,T[]> map)
Put all the T[] entries from the map in the dictionary.boolean
remove(String key)
Remove an entry.int
size()
Get the number of dictionary entries.FieldArrayDictionary<T>
toFieldArrayDictionary()
Creates a "field" values dictionary.Map<String,Object>
toMap()
Create a map from the instance.String
toString()
Get a string representation of the dictionary.
-
-
-
Constructor Detail
-
FieldDataDictionary
public FieldDataDictionary(Field<T> field)
Constructor withdefault initial capacity
.- Parameters:
field
- field to which elements belong
-
FieldDataDictionary
public FieldDataDictionary(Field<T> field, Map<String,Object> map)
Constructor from a map.- Parameters:
field
- field to which the elements belongmap
- map to use for initializing entries
-
FieldDataDictionary
public FieldDataDictionary(FieldDataDictionary<T> dictionary)
Constructor from another dictionary.- Parameters:
dictionary
- dictionary to use for initializing entries
-
-
Method Detail
-
toFieldArrayDictionary
public FieldArrayDictionary<T> toFieldArrayDictionary()
Creates a "field" values dictionary.Creates a DoubleArrayDictionary with all double[] values contained in the instance.
- Returns:
- a double values dictionary
-
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.
-
size
public int size()
Get the number of dictionary entries.- Returns:
- number of dictionary 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
-
putAllFields
public void putAllFields(Map<String,T[]> map)
Put all the T[] entries from the map in the dictionary.- Parameters:
map
- map to copy into the instance
-
putAll
public void putAll(Map<String,Object> map)
Put all the entries from the map in the dictionary.- Parameters:
map
- map to copy into the instance
-
putAll
public void putAll(FieldDataDictionary<T> 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 FieldDataDictionary.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
-
getData
public List<FieldDataDictionary.Entry> getData()
Get an unmodifiable view of the dictionary entries.- Returns:
- unmodifiable view of the dictionary entries
-
getField
public Field<T> getField()
Get the field to which elements belong.- Returns:
- the field to which elements belong
-
-