Module org.jfree.chart3d
Package org.jfree.chart3d.data
Class DefaultKeyedValues<K extends Comparable<K>,T>
java.lang.Object
org.jfree.chart3d.data.DefaultKeyedValues<K,T>
- Type Parameters:
K- the key type (must implement Comparable).T- the value type.
- All Implemented Interfaces:
Serializable,KeyedValues<K,,T> Values<T>
public final class DefaultKeyedValues<K extends Comparable<K>,T>
extends Object
implements KeyedValues<K,T>, Serializable
A list of
This is the basic structure of the data required for a pie chart.
NOTE: This class is serializable, but the serialization format is subject to change in future releases and should not be relied upon for persisting instances of this class.
(key, value) pairs.
This is the basic structure of the data required for a pie chart.
NOTE: This class is serializable, but the serialization format is subject to change in future releases and should not be relied upon for persisting instances of this class.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new (empty) list of keyed values.DefaultKeyedValues(List<K> keys) Creates a new instance with the specified keys (each associated with anullvalue). -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all the data.booleanTests this instance for equality with an arbitrary object.doublegetDoubleValue(int item) Returns the value for the specified item, as a double primitive, provided that the data value is an instance ofNumber.intReturns the index of the item with the specified key, or-1if there is no such item.intReturns the number of items in the list.getKey(int index) Returns the key for the item with the specified index.getKeys()Returns a list of all the keys.getValue(int item) Returns the value for the specified item.Returns the value with the specified key.voidAdds a value or, if there is an existing value with the same key, updates an existing value.voidremove(int index) Removes the item with the specified index.voidRemoves the item with the specified key, if there is one.
-
Constructor Details
-
DefaultKeyedValues
public DefaultKeyedValues()Creates a new (empty) list of keyed values. -
DefaultKeyedValues
Creates a new instance with the specified keys (each associated with anullvalue). There is usually no need to specify any keys in advance, so you will normally use the default constructor. This constructor is provided for the convenience of some internal code.- Parameters:
keys- the keys (nullnot permitted).
-
-
Method Details
-
clear
Clears all the data. -
put
Adds a value or, if there is an existing value with the same key, updates an existing value.- Parameters:
key- the key (nullnot permitted)value- the value.
-
remove
Removes the item with the specified key, if there is one.- Parameters:
key- the key (nullnot permitted).
-
remove
Removes the item with the specified index.- Parameters:
index- the index.
-
getKey
Returns the key for the item with the specified index.- Specified by:
getKeyin interfaceKeyedValues<K extends Comparable<K>,T> - Parameters:
index- the item index.- Returns:
- The key.
-
getIndex
Returns the index of the item with the specified key, or-1if there is no such item.- Specified by:
getIndexin interfaceKeyedValues<K extends Comparable<K>,T> - Parameters:
key- the key (nullnot permitted).- Returns:
- The item index, or
-1.
-
getKeys
Returns a list of all the keys. Note that the list will be a copy, so modifying it will not impact this data structure.- Specified by:
getKeysin interfaceKeyedValues<K extends Comparable<K>,T> - Returns:
- A list of keys (possibly empty, but never
null).
-
getValue
Returns the value with the specified key.- Specified by:
getValuein interfaceKeyedValues<K extends Comparable<K>,T> - Parameters:
key- the key (nullnot permitted).- Returns:
- The value (possibly
null).
-
getItemCount
Returns the number of items in the list.- Specified by:
getItemCountin interfaceValues<K extends Comparable<K>>- Returns:
- The number of items in the list.
-
getValue
Returns the value for the specified item.- Specified by:
getValuein interfaceValues<K extends Comparable<K>>- Parameters:
item- the item index.- Returns:
- The value (possibly
null).
-
getDoubleValue
Returns the value for the specified item, as a double primitive, provided that the data value is an instance ofNumber.- Specified by:
getDoubleValuein interfaceValues<K extends Comparable<K>>- Parameters:
item- the item index.- Returns:
- The value.
-
equals
Tests this instance for equality with an arbitrary object.
-