java - Looking for data structure -


looking data structure have these properties:

  1. fixed size (like array).
  2. cannot contain same elements (like hashset).
  3. ability remove element position (like e remove(int i) in arraylist).
  4. set element in position, if empty, otherwise throw exception.

is there such data structure? or need implement myself?

maybe class t [] , hashset<t>. if hashset contains element added, it's duplicate. if t [] has non-null (or whatever flag), element occupied. remove, you'd need remove both data structures. size can limited through t [].

with 4 operations o(1) time.


Comments