Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## prea.data.structure
Class DataMap<Key extends java.lang.Comparable<Key>,Val>

    java.lang.Object
      prea.data.structure.DataMap<Key,Val>

All Implemented Interfaces:
  java.lang.Iterable<Key>

    public class DataMap<Key extends java.lang.Comparable<Key>,Val>

extends java.lang.Object
implements java.lang.Iterable<Key>

This is a class implementing HashMap-based data map. This data structure is used for implementing sparse vector and matrix.

Since:
  2012. 4. 20
Version:
  1.1
Author:
  Joonseok Lee

Field Summary
`private java.util.HashMap<Key,Val>` | `map` Key-value mapping structure

Constructor Summary
`DataMap()` Basic constructor without specifying the capacity.
`DataMap(int capacity)` A constructor specifying the capacity.

Method Summary
`boolean` | `contains(Key key)` Check whether the map has a specific key inside it.
`Val` | `get(Key key)` Get a data value by the given key.
`int` | `itemCount()` Count the number of elements in the map.
`java.util.Iterator<Key>` | `iterator()` Get an iterator for the map.
`void` | `put(Key key, Val value)` Set a data value with the given key.
`Val` | `remove(Key key)` Remove a data element with the given key.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### map

    private java.util.HashMap<Key extends java.lang.Comparable<Key>,Val> map

  Key-value mapping structure

Constructor Detail

### DataMap

    public DataMap()

  Basic constructor without specifying the capacity.

### DataMap

    public DataMap(int capacity)

  A constructor specifying the capacity. BE CAREFUL TO USE THIS! Never set the capacity too larger than actually needed. It will waste the memory space, reducing performance of your program.

Method Detail

### get

    public Val get(Key key)

  Get a data value by the given key.

  Parameters:
    `key` - The key to search.
  Returns:
    The data value associated with the given key.

### put

    public void put(Key key,
                    Val value)

  Set a data value with the given key.

  Parameters:
    `key` - The key to set.
    `value` - The data value associated with the given key.

### remove

    public Val remove(Key key)

  Remove a data element with the given key.

  Parameters:
    `key` - The key to remove.
  Returns:
    The data value deleted with the given key.

### contains

    public boolean contains(Key key)

  Check whether the map has a specific key inside it.

  Parameters:
    `key` - The key to search.
  Returns:
    true if the map has the given key, false otherwise.

### iterator

    public java.util.Iterator<Key> iterator()

  Get an iterator for the map.

  Specified by:
    `iterator` in interface `java.lang.Iterable<Key extends java.lang.Comparable<Key>>`
  Returns:
    The Iterator instance for the map.

### itemCount

    public int itemCount()

  Count the number of elements in the map.

  Returns:
    The number of items in the map.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD