From Algorithm Wiki
Revision as of 05:42, 4 June 2015 by Azaza
k = k+1; A[X] = k; B[k] = X;
return (A[X] < k) and (B[A[X]] == X)
A[B[k]] = A[X]; B[A[X]] = B[k]; k = k-1;
Please note that this data structure doesn't support inserting the same X more than once.