Skip to content

Instantly share code, notes, and snippets.

@Frdnspnzr
Created November 15, 2012 09:23
Show Gist options
  • Save Frdnspnzr/4077605 to your computer and use it in GitHub Desktop.
Save Frdnspnzr/4077605 to your computer and use it in GitHub Desktop.
Awesome bitvector array stuff
public class newBitvektor
{
private int top=0;
private int[] data;
private int[] from;
public int[] to;
public newBitvektor(int i){
this.data = new int[i];
this.from = new int[i];
this.to = new int[i];
}
public void set(int i, int value)
{
data[i]=value;
from[i]=top;
to[top]=i;
top++;
}
public int get(int i) {
if ((from[i]<top) && (to[from[i]]==i)) return data[i];
return 0;
}
public void delete(int i) {
data[i] = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment