Documentation of 'org.jplot2d.util.SparseArray' Java class
SparseArray
org.jplot2d.util

Class SparseArray<E>

  • All Implemented Interfaces:
    java.lang.Cloneable


    public class SparseArray<E>
    extends java.lang.Object
    implements java.lang.Cloneable
    SparseArrays map integers to Objects. Unlike a normal array of Objects, there can be gaps in the indices. It is intended to be more efficient than using a HashMap to map Integers to Objects.
    • Constructor Summary

      Constructors 
      Constructor and Description
      SparseArray()
      Creates a new SparseArray containing no mappings.
      SparseArray(int initialCapacity)
      Creates a new SparseArray containing no mappings that will not require any additional memory allocation to store the specified number of mappings.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void clear()
      Removes all key-value mappings from this SparseArray.
      SparseArray<E> copy() 
      E get(int key)
      Gets the Object mapped from the specified key, or null if no such mapping has been made.
      void put(int key, E value)
      Adds a mapping from the specified key to the specified value, replacing the previous mapping from the specified key if there was one.
      void remove(int key)
      Removes the mapping from the specified key, if there was any.
      int size()
      Returns the number of key-value mappings that this SparseArray currently stores.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SparseArray

        public SparseArray()
        Creates a new SparseArray containing no mappings.
      • SparseArray

        public SparseArray(int initialCapacity)
        Creates a new SparseArray containing no mappings that will not require any additional memory allocation to store the specified number of mappings.
    • Method Detail

      • get

        public E get(int key)
        Gets the Object mapped from the specified key, or null if no such mapping has been made.
      • remove

        public void remove(int key)
        Removes the mapping from the specified key, if there was any.
      • put

        public void put(int key,
                        E value)
        Adds a mapping from the specified key to the specified value, replacing the previous mapping from the specified key if there was one.
      • size

        public int size()
        Returns the number of key-value mappings that this SparseArray currently stores.
      • clear

        public void clear()
        Removes all key-value mappings from this SparseArray.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.