Is there a java collection that only allow unique object in and with a get (index i) method ?
i firstly think of a treeSet but there is no get methods in ...
what i want be able to :
// replace object with any class that implement the right things to make it work
Collection<Object> collection = dunno<Object>();
Object o = new Object()
Object o2 = new Object()
collection.add(o)
collection.add(o)
collection.size() // should get 1
collection.get(0) // should return o
// let's suppose that o2 is lower than o (if the collection doesn't sort the way i want i can change it anyway)
collection.add(o2)
collection.get(0) // should return o2
so basicly like a treeSet but with a get methods does anyone know something like that ?