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 anull
value). -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears all the data.boolean
Tests this instance for equality with an arbitrary object.double
getDoubleValue
(int item) Returns the value for the specified item, as a double primitive, provided that the data value is an instance ofNumber
.int
Returns the index of the item with the specified key, or-1
if there is no such item.int
Returns 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.void
Adds a value or, if there is an existing value with the same key, updates an existing value.void
remove
(int index) Removes the item with the specified index.void
Removes 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 anull
value). 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 (null
not 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 (null
not permitted)value
- the value.
-
remove
Removes the item with the specified key, if there is one.- Parameters:
key
- the key (null
not 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:
getKey
in 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-1
if there is no such item.- Specified by:
getIndex
in interfaceKeyedValues<K extends Comparable<K>,
T> - Parameters:
key
- the key (null
not 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:
getKeys
in 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:
getValue
in interfaceKeyedValues<K extends Comparable<K>,
T> - Parameters:
key
- the key (null
not permitted).- Returns:
- The value (possibly
null
).
-
getItemCount
Returns the number of items in the list.- Specified by:
getItemCount
in interfaceValues<K extends Comparable<K>>
- Returns:
- The number of items in the list.
-
getValue
Returns the value for the specified item.- Specified by:
getValue
in 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:
getDoubleValue
in interfaceValues<K extends Comparable<K>>
- Parameters:
item
- the item index.- Returns:
- The value.
-
equals
Tests this instance for equality with an arbitrary object.
-