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 (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

    Constructors
    Constructor
    Description
    Creates a new (empty) list of keyed values.
    Creates a new instance with the specified keys (each associated with a null value).
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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 of Number.
    int
    getIndex(K key)
    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.
    Returns a list of all the keys.
    getValue(int item)
    Returns the value for the specified item.
    getValue(K key)
    Returns the value with the specified key.
    void
    put(K key, T value)
    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
    remove(K key)
    Removes the item with the specified key, if there is one.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DefaultKeyedValues

      Creates a new (empty) list of keyed values.
    • DefaultKeyedValues

      public DefaultKeyedValues(List<K> keys)
      Creates a new instance with the specified keys (each associated with a null 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

      public void clear()
      Clears all the data.
    • put

      public void put(K key, T value)
      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

      public void remove(K key)
      Removes the item with the specified key, if there is one.
      Parameters:
      key - the key (null not permitted).
    • remove

      public void remove(int index)
      Removes the item with the specified index.
      Parameters:
      index - the index.
    • getKey

      public K getKey(int index)
      Returns the key for the item with the specified index.
      Specified by:
      getKey in interface KeyedValues<K extends Comparable<K>,T>
      Parameters:
      index - the item index.
      Returns:
      The key.
    • getIndex

      public int getIndex(K key)
      Returns the index of the item with the specified key, or -1 if there is no such item.
      Specified by:
      getIndex in interface KeyedValues<K extends Comparable<K>,T>
      Parameters:
      key - the key (null not permitted).
      Returns:
      The item index, or -1.
    • getKeys

      public List<K> 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 interface KeyedValues<K extends Comparable<K>,T>
      Returns:
      A list of keys (possibly empty, but never null).
    • getValue

      public T getValue(K key)
      Returns the value with the specified key.
      Specified by:
      getValue in interface KeyedValues<K extends Comparable<K>,T>
      Parameters:
      key - the key (null not permitted).
      Returns:
      The value (possibly null).
    • getItemCount

      public int getItemCount()
      Returns the number of items in the list.
      Specified by:
      getItemCount in interface Values<K extends Comparable<K>>
      Returns:
      The number of items in the list.
    • getValue

      public T getValue(int item)
      Returns the value for the specified item.
      Specified by:
      getValue in interface Values<K extends Comparable<K>>
      Parameters:
      item - the item index.
      Returns:
      The value (possibly null).
    • getDoubleValue

      public double getDoubleValue(int item)
      Returns the value for the specified item, as a double primitive, provided that the data value is an instance of Number.
      Specified by:
      getDoubleValue in interface Values<K extends Comparable<K>>
      Parameters:
      item - the item index.
      Returns:
      The value.
    • equals

      public boolean equals(Object obj)
      Tests this instance for equality with an arbitrary object.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to test against (null permitted).
      Returns:
      A boolean.