From 5f3fb9afece2125cbeba79d61a8d88460b7878d7 Mon Sep 17 00:00:00 2001 From: Joshua Rahm Date: Tue, 27 Jan 2015 18:40:32 -0700 Subject: initial commit --- .../src/com/modulus/common/collections/IntMap.java | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 project/JavaCommon/src/com/modulus/common/collections/IntMap.java (limited to 'project/JavaCommon/src/com/modulus/common/collections/IntMap.java') diff --git a/project/JavaCommon/src/com/modulus/common/collections/IntMap.java b/project/JavaCommon/src/com/modulus/common/collections/IntMap.java new file mode 100644 index 0000000..558cd9f --- /dev/null +++ b/project/JavaCommon/src/com/modulus/common/collections/IntMap.java @@ -0,0 +1,84 @@ +package com.modulus.common.collections; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class IntMap implements Map { + private List list = new ArrayList(); + + @Override + public void clear() { + this.list.clear(); + } + + @Override + public boolean containsKey(Object arg0) { + if( arg0 instanceof Integer) + return ((Integer) arg0) < this.list.size(); + + return false; + } + + @Override + public boolean containsValue(Object arg0) { + return list.contains(arg0); + } + + @Override + public Set> entrySet() { + throw new RuntimeException("Not Implemented (At The Moment)"); + } + + @Override + public T get(Object arg0) { + try{ + return list.get( (Integer)arg0 ); + } catch(ClassCastException e){ + return null; + } + } + + @Override + public boolean isEmpty() { + return list.isEmpty(); + } + + @Override + public Set keySet() { + return new HashSet( Arrays.asList( Collections2.rangeAsObjects(0, list.size()) ) ); + } + + @Override + public T put(Integer arg0, T arg1) { + return list.set(arg0, arg1); + } + + @Override + public void putAll(Map arg0) { + throw new RuntimeException("Not Implemented At the Moment"); + } + + @Override + public T remove(Object arg0) { + // TODO Auto-generated method stub + return null; + } + + @Override + public int size() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public Collection values() { + // TODO Auto-generated method stub + return null; + } + +} -- cgit