Hash reliability for uniqueness?
Mathematica's associations do not permit duplicate keys. You could make use of this.
I make a simple association to illustrate my point. Since I am only interested in the keys, the values are all zero.
With[{n = 3},
stuff = AssociationThread[Array[thing, n], ConstantArray[0, n]]]
Association[thing[1] -> 0, thing[2] -> 0, thing[3] -> 0]
Appending a new element.
AssociateTo[stuff, thing[42] -> 0]
Association[thing[1] -> 0, thing[2] -> 0, thing[3] -> 0, thing[42] -> 0]
But I can't add a duplicate.
AssociateTo[stuff, thing[2] -> 0]
Association[thing[1] -> 0, thing[3] -> 0, thing[42] -> 0, thing[2] -> 0]
Yes, the order has changed but since it's a hash, the order shouldn't matter.
When the list form is needed:
myList = Keys @ stuff
{thing[1], thing[2], thing[3], thing[42]}
Placeholder answer, because I am just about to be called into a meeting...
I would use Downvalues, and have used them successfully for MMA version 9.0 and earlier
Clear[mylistDownvalues];
mylistDownvalues[_]=False;
(* how you fill with entries, set downvalues *)
mylistDownvalues[entry1]=1;
mylistDownvalues[entry2]=2;
mylistDownvalues[entry3]=3;
mylistDownvalues[entry4]=4;
mylistDownvalues[entry5]=5;
(* trivial to make a helper function *)
myCount=6;
mylistHelper[v_]:=(mylistDownvalues[v]=myCount;myCount+=1)
mylistHelper[entry6];
mylistHelper[entry7];
(* how you get list of entries *)
mylist = SortBy[Select[#[[1,1,1]]->#[[2]]& /@
DownValues[mylistDownvalues],#[[2]]=!=False&],#[[2]]&];
(* Out[]= {entry1->1,entry2->2,entry3->3,entry4->4, *)
(* entry5->5,entry6->6,entry7->7} *)
(* membership test is fast, insertion is fast, getting index is fast *)
(* membership *)
mylistMemberQ[v_]:=mylistDownvalues[v]=!=False
mylistMemberQ[entry4]
(* Out[]= True *)
mylistMemberQ[entry8]
(* Out[]= False *)
(* getting index *)
mylistDownvalues[entry5]
(* Out[]= 5 *)