// public static string IntToBinaryString(int number) { // string binStr = ""; // while (number != 0) { // binStr = (number & 1) + binStr; // number = number >>> 1; // } // if (binStr == "") // binStr = "0"; // return binStr; // } // // public static string IntToBinaryString(long number) { // string binStr = ""; // while (number > 0) { // binStr = (number & 1) + binStr; // number = number >>> 1; // } // if (binStr == "") // binStr = "0"; // return binStr; // } ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// public static Obj Copy(UnaryTable[] tables) { int count = 0; for (int i = 0; i < tables.Length; i++) { count += tables[i].count; } if (count == 0) { return(EmptyRelObj.singleton); } Obj[] objs = new Obj[count]; int next = 0; for (int i = 0; i < tables.Length; i++) { UnaryTable table = tables[i]; SurrObjMapper mapper = table.mapper; long[] bitmap = table.bitmap; for (int j = 0; j < bitmap.Length; j++) { long mask = bitmap[j]; for (int k = 0; k < 64; k++) { if (Miscellanea.BitIsSet64(mask, k)) { objs[next++] = mapper(k + 64 * j); } } } } Debug.Assert(next == count); return(Builder.CreateSet(objs, objs.Length)); }
public Iter(int index, UnaryTable table) { this.table = table; if (table.count == 0) { this.index = 64 * table.bitmap.Length; } else { this.index = index; if (!table.Contains(0)) { Next(); } } }
public static void Write(DataWriter writer, int fieldSymbId, UnaryTable[] tables, int indentation, bool indentFirstLine, bool writeSeparator) { string baseWs = new string(Array.Repeat(' ', indentation)); string entryWs = new string(Array.Repeat(' ', indentation + 2)); int count = 0; for (int i = 0; i < tables.Length; i++) { count += tables[i].Size(); } if (indentFirstLine) { writer.Write(baseWs); } writer.Write(SymbObj.IdxToStr(fieldSymbId)); writer.Write(": ["); if (count > 0) { writer.Write("\n"); int written = 0; for (int i = 0; i < tables.Length; i++) { UnaryTable table = tables[i]; SurrObjMapper mapper = table.mapper; UnaryTable.Iter it = table.GetIter(); while (!it.Done()) { writer.Write(entryWs); Obj obj = mapper(it.Get()); ObjPrinter.PrintNoFlush(obj, writer); written++; writer.Write(written < count ? ",\n" : "\n"); it.Next(); } } Debug.Assert(written == count); writer.Write(baseWs); } writer.Write(writeSeparator ? "],\n" : "]\n"); }
public UnaryTableUpdater(string relvarName, UnaryTable table, ValueStoreUpdater store) { this.relvarName = relvarName; this.table = table; this.store = store; }