Getter for original map in IntMap

This commit is contained in:
KennyTV 2020-06-08 14:23:11 +02:00
parent 1ad559212e
commit 623cdaf881
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
4 changed files with 25 additions and 3 deletions

View File

@ -30,8 +30,8 @@ import java.util.Map.Entry;
public class ConnectionData {
private static final BlockChangeRecord[] A = new BlockChangeRecord[0];
public static BlockConnectionProvider blockConnectionProvider;
static IntObjectMap<String> idToKey = CollectionUtil.createIntObjectMap(8581);
static Map<String, Integer> keyToId = new HashMap<>(8581);
static IntObjectMap<String> idToKey = CollectionUtil.createIntObjectMap(8582);
static Map<String, Integer> keyToId = new HashMap<>(8582);
static IntObjectMap<ConnectionHandler> connectionHandlerMap = CollectionUtil.createIntObjectMap(1);
static IntObjectMap<BlockData> blockConnectionData = CollectionUtil.createIntObjectMap(1);
static IntSet occludingStates = CollectionUtil.createIntSet(377);

View File

@ -1,5 +1,7 @@
package us.myles.ViaVersion.util.fastutil;
import java.util.Map;
/**
* Very simple wrapping interface to either be implemented by a HashMap or FastUtil's OpenHashMap.
*/
@ -32,4 +34,13 @@ public interface IntMap {
* @see java.util.HashMap#remove(Object)
*/
int remove(int key);
/**
* Returns the underlying map for usage of not implemented methods of this class.
*
* @return original map
* @deprecated will cause wrapping if it is a FastUtil collection
*/
@Deprecated
Map<Integer, Integer> getMap();
}

View File

@ -35,4 +35,9 @@ final class WrappedFUIntMap implements IntMap {
public int remove(int key) {
return map.remove(key);
}
@Override
public Map<Integer, Integer> getMap() {
return map;
}
}

View File

@ -32,6 +32,12 @@ final class WrappedIntMap implements IntMap {
@Override
public int remove(int key) {
return map.remove(key);
Integer removed = map.remove(key);
return removed != null ? removed : -1;
}
@Override
public Map<Integer, Integer> getMap() {
return map;
}
}