net.ranides.assira.collection.map
Class SwitchMap<K extends Comparable<K>,V>

java.lang.Object
  extended by net.ranides.assira.collection.map.SwitchMap<K,V>
Type Parameters:
K -
V -
All Implemented Interfaces:
Map<K,V>

public final class SwitchMap<K extends Comparable<K>,V>
extends Object
implements Map<K,V>

Mapa używana do wyszukiwania po kluczu w czasie O(logN) przy minimalnym narzucie pamięciowym. Dodawanie kluczy do mapy jest niedozwolone. Mapa wolniejsza od HashMap ale ekstremalnie efektywniejsza pamięciowo.

Author:
ranides

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
SwitchMap(Collection<K> keys)
          Tworzy nową mapę wypełniając podanymi kluczami.
SwitchMap(K[] keys)
          Tworzy nową mapę wypełniając podanymi kluczami.
SwitchMap(K[] keys, V[] values)
          Tworzy nową mapę wypełniając wskazanymi kluczami i przyporządkowując im wskazane wartości.
SwitchMap(Map.Entry<K,V>[] entries)
           
SwitchMap(SortedMap<? extends K,? extends V> tree)
          Tworzy nową mapę wypełniając wskazanymi danymi.
 
Method Summary
 void clear()
          Deprecated.  
 boolean containsKey(Object key)
           Złożoność: O(logN)
 boolean containsValue(Object value)
           Złożoność: O(N)
 Set<Map.Entry<K,V>> entrySet()
           
 V get(Object key)
           Złożoność: O(logN)
 boolean isEmpty()
           Złożoność: O(1)
 Set<K> keySet()
           
 V put(K key, V value)
          Replaces the old value associated with key by the specified value.
 void putAll(Map<? extends K,? extends V> map)
           Złożoność: O(NlogN).
 V remove(Object key)
          Deprecated.  
 int size()
           Złożoność: O(1)
 Collection<V> values()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

SwitchMap

public SwitchMap(K[] keys,
                 V[] values)
Tworzy nową mapę wypełniając wskazanymi kluczami i przyporządkowując im wskazane wartości.

Parameters:
keys -
values -

SwitchMap

public SwitchMap(Map.Entry<K,V>[] entries)

SwitchMap

public SwitchMap(SortedMap<? extends K,? extends V> tree)
Tworzy nową mapę wypełniając wskazanymi danymi.

Parameters:
tree -

SwitchMap

public SwitchMap(K[] keys)
Tworzy nową mapę wypełniając podanymi kluczami. Wartości przypisane kluczom można modyfikować w późniejszym czasie.

Parameters:
keys -

SwitchMap

public SwitchMap(Collection<K> keys)
Tworzy nową mapę wypełniając podanymi kluczami. Wartości przypisane kluczom można modyfikować w późniejszym czasie.

Parameters:
keys -
Method Detail

size

public int size()

Złożoność: O(1)

Specified by:
size in interface Map<K extends Comparable<K>,V>
Returns:

isEmpty

public boolean isEmpty()

Złożoność: O(1)

Specified by:
isEmpty in interface Map<K extends Comparable<K>,V>
Returns:

containsKey

public boolean containsKey(Object key)

Złożoność: O(logN)

Specified by:
containsKey in interface Map<K extends Comparable<K>,V>
Returns:

containsValue

public boolean containsValue(Object value)

Złożoność: O(N)

Specified by:
containsValue in interface Map<K extends Comparable<K>,V>
Returns:

get

public V get(Object key)

Złożoność: O(logN)

Specified by:
get in interface Map<K extends Comparable<K>,V>
Returns:

put

public V put(K key,
             V value)
Replaces the old value associated with key by the specified value. If the map previously didn't contain a mapping for the key, exception is thrown. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)

Złożoność: O(logN)

Specified by:
put in interface Map<K extends Comparable<K>,V>
Parameters:
key - existing key in the map, with which the specified value is to be associated
value - value to be associated with the specified key
Returns:
the previous value associated with key
Throws:
UnsupportedOperationException - if the specified key does not exist in the map

remove

public V remove(Object key)
Deprecated. 

Metoda nie obsługiwana.

Specified by:
remove in interface Map<K extends Comparable<K>,V>
Parameters:
key -
Returns:
Throws:
UnsupportedOperationException - zawsze

putAll

public void putAll(Map<? extends K,? extends V> map)

Złożoność: O(NlogN).

Specified by:
putAll in interface Map<K extends Comparable<K>,V>
Parameters:
map -

clear

public void clear()
Deprecated. 

Metoda nie obsługiwana.

Specified by:
clear in interface Map<K extends Comparable<K>,V>
Throws:
UnsupportedOperationException - zawsze

keySet

public Set<K> keySet()
Specified by:
keySet in interface Map<K extends Comparable<K>,V>

values

public Collection<V> values()
Specified by:
values in interface Map<K extends Comparable<K>,V>

entrySet

public Set<Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface Map<K extends Comparable<K>,V>


Copyright © 2013. All Rights Reserved.