public Prefix ExtendLeft() { var newBits = new BitArray(Bits.Count + 1); foreach (int i in Enumerable.Range(0, Bits.Count)) { newBits[i] = Bits[i]; } var left = new Prefix { Bits = newBits }; left.SetKey(); return(left); }
public Prefix Sibling() { var s = new Prefix { Bits = Bits }; if (s.Bits.Count == 0) { Console.WriteLine("Warning: There should be no calling of Sibling on empty prefix!"); } else { s.Bits[s.Bits.Count - 1] = !s.Bits[s.Bits.Count - 1]; } s.SetKey(); return(s); }
public Prefix ExtendRight() { var newBits = new BitArray(Bits.Count + 1); foreach (int i in Enumerable.Range(0, Bits.Count)) { newBits[i] = Bits[i]; } newBits[newBits.Count - 1] = true; var right = new Prefix { Bits = newBits }; right.SetKey(); return(right); }
internal Prefix Parent() { if (Bits.Count == 0) { Console.WriteLine("Warning: There should be no calling of Parent on empty prefix!"); } var newBits = new BitArray(Math.Max(0, Bits.Count - 1)); foreach (int i in Enumerable.Range(0, newBits.Count)) { newBits[i] = Bits[i]; } var a = new Prefix { Bits = newBits }; a.SetKey(); return(a); }