Created
November 15, 2012 09:23
-
-
Save Frdnspnzr/4077605 to your computer and use it in GitHub Desktop.
Awesome bitvector array stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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