ArrayMAP介绍

它不是一个适应大数据的数据结构,相比传统的HashMap速度要慢,因为查找方法是二分法,并且当你删除或者添加数据时,会对空间重新调整,在使用大量数据时,效率并不明显,低于50%。


ArrayMap is a generic key->value mapping data structure that is designed to be more memory efficient than a traditionaljava.util.HashMap. It keeps its mappings in an array data structure -- an integer array of hash codes for each item, and an Object array of the key/value pairs. This allows it to avoid having to create an extra object for every entry put in to the map, and it also tries to control the growth of the size of these arrays more aggressively (since growing them only requires copying the entries in the array, not rebuilding a hash map).


Note that this implementation is not intended to be appropriate for data structures that may contain large numbers of items. It is generally slower than a traditional HashMap, since lookups require a binary search and adds and removes require inserting and deleting entries in the array. 

public final class ArrayMap<K, V> implements Map<K, V> {

static Object[] mBaseCache;
static int mBaseCacheSize;

int[] mHashes; //mHashes数组中保存的是每一项的HashCode值

Object[] mArray; //,mArray中就是键值对,每两个元素代表一个键值对,前面保存key,后面的保存value

}



public interface MAP <K,V> {

int size();

boolean isEmpty();

boolean containsKey(Object key);

boolean containsVlaue(Object value);

V get(Object key);

V put(K key, V value);

V remove(Object key);

void putAll(Map<? extends K, ? extends V> m);

void clear();

Set<K> keySet();

Collection<V> values();

boolean equals(Object o);

int hasCode();


}

微笑


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值