Commits

Ville Saalo  committed 3015d57

Implemented the TwoWayMap.

  • Participants
  • Parent commits 310534b

Comments (0)

Files changed (2)

File src/com/saibotd/bitbeaker/TwoWayMap.java

 	}
 	
 	public V getByKey(K key) {
-		throw new UnsupportedOperationException();
+		if (map.containsKey(key))  {
+			return map.get(key);
+		}
+		return defaultValue;
 	}
 	
 	public K getByValue(V value) {
-		throw new UnsupportedOperationException();
+		if(reversedMap.containsKey(value)) {
+			return reversedMap.get(value);
+		}
+		return defaultKey;
 	}
 	
 	public void put(K key, V value) {
-		throw new UnsupportedOperationException();
+		V oldValue = map.get(key);
+		map.put(key, value);
+		reversedMap.remove(oldValue);
+		reversedMap.put(value, key);
 	}
 }

File src/com/saibotd/bitbeaker/tests/BitbeakerInstrumentationTestRunner.java

 		suite.addTestSuite(BitbeakerTest.class);
 		suite.addTestSuite(HelperTest.class);
 		suite.addTestSuite(LauncherActivityTest.class);
-		//suite.addTestSuite(TwoWayMapTest.class);
+		suite.addTestSuite(TwoWayMapTest.class);
 		
 		return suite;
 	}