/* * This file is part of SpoutcraftPlugin. * * Copyright (c) 2011 SpoutcraftDev <http://spoutcraft.org//> * SpoutcraftPlugin is licensed under the GNU Lesser General Public License. * * SpoutcraftPlugin is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * SpoutcraftPlugin is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.getspout.spoutapi.util.map; import gnu.trove.TDoubleCollection; import gnu.trove.iterator.TIntDoubleIterator; import gnu.trove.map.hash.TIntDoubleHashMap; import gnu.trove.set.TIntSet; /** * A simplistic map that supports (byte, short, byte) keys, using a trove int double hashmap in the backend. */ public class TByteShortByteKeyedDoubleHashMap extends TByteShortByteKeyedMap { private TIntDoubleHashMap map; public TByteShortByteKeyedDoubleHashMap() { map = new TIntDoubleHashMap(100); } public TByteShortByteKeyedDoubleHashMap(int capacity) { map = new TIntDoubleHashMap(capacity); } public double put(int key1, int key2, int key3, double value) { int key = key(key1, key2, key3); return map.put(key, value); } public double get(int key1, int key2, int key3) { int key = key(key1, key2, key3); return map.get(key); } public boolean containsKey(int key1, int key2, int key3) { int key = key(key1, key2, key3); return map.containsKey(key); } public void clear() { map.clear(); } public boolean containsValue(double val) { return map.containsValue(val); } public boolean increment(int key1, int key2, int key3) { int key = key(key1, key2, key3); return map.increment(key); } public boolean isEmpty() { return map.isEmpty(); } public TIntDoubleIterator iterator() { return map.iterator(); } public TIntSet keySet() { return map.keySet(); } public int[] keys() { return map.keys(); } public double remove(int key1, int key2, int key3) { int key = key(key1, key2, key3); return map.remove(key); } public int size() { return map.size(); } public TDoubleCollection valueCollection() { return map.valueCollection(); } public double[] values() { return map.values(); } }