The Simple Collections Facade for Java makes it easy to switch between Collections frameworks. It allows users using Java Collections now to switch to Trove the next day, and FastUtil the day after without changing any code. It also allows users to use Set from Trove and Map from FastUtil.
Simply include the scf4j-api and one of the following in your classpath:
- scf4j-jdk
- scf4j-trove4j
- scf4j-fastutil
Using a single Collections framework.
// to use the default implementation
IntIntMap map = MapFactory.createIntIntHashMap();
// do something with map
map.push(1,2);
map.get(1);
Using multiple Collections frameworks.
// to use Trove's Map and FastUtil's Set
IntIntMap troveMap = MapFactory.createIntIntHashMap(TroveMapFactory.class);
IntSet fastUtilSet = SetFactory.createIntHashSet(FastUtilSetFactory.class);
// do something with map
troveMap.push(1,2);
troveMap.get(1);
// do something with set
fastUtilSet.add(1);
fastUtilSet.contains(1);
This project is inspired and based on the Simple Logging Facade for Java (SLF4J)
- How to support operations that framework A provides but framework B doesn't.
Let me know if you have any ideas on how to resolve the above issues, want to request new features or contribute to the project.