public PerfectDominatingSet(int n) : base(n) { Sigma = new BitSet(0, MaxSize); Sigma = !Sigma; Rho = new BitSet(0, MaxSize, new int[] { 1 }); }
public static Tree Expand(Tree tree, BitSet parent, int node) { Tree newTree = new Tree(); Queue<BitSet> queue = new Queue<BitSet>(); queue.Enqueue(tree.Root); while (queue.Count > 0) { BitSet set = queue.Dequeue(); BitSet child; if (tree.LeftChild.TryGetValue(set, out child)) { queue.Enqueue(child); } if (tree.RightChild.TryGetValue(set, out child)) { queue.Enqueue(child); } if (parent.IsSubsetOf(set)) { set += node; } newTree.Insert(set); } newTree.Insert(parent); newTree.Insert(newTree.Root * node); return newTree; }
public IndependentSet(int n) : base(n) { Sigma = new BitSet(0, MaxSize, new int[] { 0 }); Rho = new BitSet(0, MaxSize); Rho = !Rho; }
public InducedMatching(int n) : base(n) { Sigma = new BitSet(0, MaxSize, new int[] { 1 }); Rho = new BitSet(0, MaxSize); Rho = !Rho; }
/// <summary> /// Short-cut to quickly create a sparse float array representing /// <code>this(new float[capacity]);</code>, but without reading through said array. /// The advantage here is that the constructor is lightning-fast in the case that /// all values in the float array are known to /// <c>== 0f</c>. /// </summary> /// <param name="capacity">The capacity of the array.</param> public SparseFloatArray(int capacity) { _capacity = capacity; _floats = null; _bits = null; _referencePoints = null; }
static CharSet() { CharSet.lowerLetters = new BitSet(); CharSet.upperLetters = new BitSet(); CharSet.letters = new BitSet(); for (int i = 0; i <= 65535; i++) { switch (char.GetUnicodeCategory((char)i)) { case UnicodeCategory.UppercaseLetter: CharSet.upperLetters.Set(i, true); CharSet.letters.Set(i, true); break; case UnicodeCategory.LowercaseLetter: CharSet.lowerLetters.Set(i, true); CharSet.letters.Set(i, true); break; case UnicodeCategory.TitlecaseLetter: case UnicodeCategory.ModifierLetter: case UnicodeCategory.OtherLetter: CharSet.letters.Set(i, true); break; } } }
// Uses depth-first search to check if the graph induced by the subgraph given as a parameter is connected // In other words, we retreive all edges from the original graph and check the subgraph for connectedness public static bool Connected(Datastructures.Graph graph, BitSet subgraph) { // Vertices that are visited Set<int> visited = new Set<int>(); // Stack of vertices yet to visit Stack<int> stack = new Stack<int>(); // Initial vertex int s = subgraph.First(); stack.Push(s); // Continue while there are vertices on the stack while (stack.Count > 0) { int v = stack.Pop(); // If we have not encountered this vertex before, then we check for all neighbors if they are part of the subgraph // If a neighbor is part of the subgraph it means that we have to push it on the stack to explore it at a later stage if (!visited.Contains(v)) { visited.Add(v); foreach (int w in graph.OpenNeighborhood(v)) if (subgraph.Contains(w)) stack.Push(w); } } // If we visited an equal number of vertices as there are vertices in the subgraph then the subgraph is connected return visited.Count == subgraph.Count; }
// Basic constructor for a dNeighborhood public DNeighborhood(BitSet vector) { _occurrences = new Dictionary<int, int>(); Vector = vector; foreach (int v in Vector) _occurrences[v] = 0; }
public void CreateBitSet() { BitSet b = new BitSet(32); b[0] = true; b[1] = false; Assert.IsTrue(b[0]); Assert.IsTrue(!b[1]); }
private static void ProcessStates(BitSet bset, Nfa current) { foreach (int current2 in bset) { List<Nfa> list = MakeNfa.spec.state_rules[current2]; list.Add(current); } }
public DominatingSet(int n) : base(n) { Sigma = new BitSet(0, MaxSize); Sigma = !Sigma; Rho = new BitSet(0, MaxSize, new int[] { 0 }); Rho = !Rho; }
public GhostObject() { Guid = new TFID(); WaitingForParent = true; UpdatePriorityScalar = 0.1f; NetFlags = new BitSet(); NetFlags.Set((UInt32) NetFlag.Ghostable); }
protected virtual void Condense(float[] floats) { if (floats.Length != _capacity) { throw new ArgumentException("bad input float array of length " + floats.Length + " for capacity: " + _capacity); } var bits = new BitSet(floats.Length); int on = 0; for (int i = 0; i < floats.Length; i++) { if (floats[i] != 0f) { bits.Set(i); on++; } } if (((float)on) / ((float)floats.Length) < ON_RATIO_CUTOFF) { // it's worth compressing if (0 == on) { // it's worth super-compressing _floats = null; _bits = null; _referencePoints = null; // capacity is good. } else { _bits = bits; _floats = new float[_bits.Cardinality()]; _referencePoints = new int[floats.Length / REFERENCE_POINT_EVERY]; int i = 0; int floatsIdx = 0; int refIdx = 0; while (i < floats.Length && (i = _bits.NextSetBit(i)) >= 0) { _floats[floatsIdx] = floats[i]; while (refIdx < i / REFERENCE_POINT_EVERY) { _referencePoints[refIdx++] = floatsIdx; } floatsIdx++; i++; } while (refIdx < _referencePoints.Length) { _referencePoints[refIdx++] = floatsIdx; } } } else { // it's not worth compressing _floats = floats; _bits = null; } }
static Dictionary<string,int> LoadNameIndex(BitAccess bits, out int age, out Guid guid) { Dictionary<string, int> result = new Dictionary<string, int>(); int ver; int sig; bits.ReadInt32(out ver); // 0..3 Version bits.ReadInt32(out sig); // 4..7 Signature bits.ReadInt32(out age); // 8..11 Age bits.ReadGuid(out guid); // 12..27 GUID if (ver != 20000404) { throw new PdbDebugException("Unsupported PDB Stream version {0}", ver); } // Read string buffer. int buf; bits.ReadInt32(out buf); // 28..31 Bytes of Strings int beg = bits.Position; int nxt = bits.Position + buf; bits.Position = nxt; // Read map index. int cnt; // n+0..3 hash size. int max; // n+4..7 maximum ni. bits.ReadInt32(out cnt); bits.ReadInt32(out max); BitSet present = new BitSet(bits); BitSet deleted = new BitSet(bits); if (!deleted.IsEmpty) { throw new PdbDebugException("Unsupported PDB deleted bitset is not empty."); } int j = 0; for (int i = 0; i < max; i++) { if (present.IsSet(i)) { int ns; int ni; bits.ReadInt32(out ns); bits.ReadInt32(out ni); string name; int saved = bits.Position; bits.Position = beg + ns; bits.ReadCString(out name); bits.Position = saved; result.Add(name, ni); j++; } } if (j != cnt) { throw new PdbDebugException("Count mismatch. ({0} != {1})", j, cnt); } return result; }
// Counts the number of independent sets in a graph, such that: // - The vertices in P are legal choices for our IS, initially set to all vertices in the graph // - None of the vertices in X are used, initially empty // The performDFS boolean is used to check if we should perform a check for connectedness on this level of the recursion private static long Compute(Graph graph, BitSet p, BitSet x, bool performDfs) { // Base case, when P and X are both empty we cannot expand the IS if (p.IsEmpty && x.IsEmpty) return 1; // Base case, if a vertex w in X has no neighbor in P, then it means that this IS will never get maximal // since we could always include w. Thus, the IS will not be valid and we return 0. foreach (int w in x) if ((graph.OpenNeighborhood(w) * p).IsEmpty) return 0; long count = 0; // If a DFS is needed we check if the graph induced by (P + X) is still connected. // If the graph is disconnected, in components c1,...,cn then we can simply count the IS of all these components // after which we simply multiply these numbers. if (performDfs) { if (!DepthFirstSearch.Connected(graph, p + x)) { count = 1; foreach (BitSet component in DepthFirstSearch.ConnectedComponents(graph, p + x)) count *= Compute(graph, component * p, component * x, false); return count; } } // Select a pivot in P to branch on // In this case we pick the vertex with the largest degree int maxDegree = -1; ; int pivot = -1; foreach (int u in p) { int deg = graph.Degree(u); if (deg > maxDegree) { maxDegree = deg; pivot = u; } } // There should always be a pivot after the selection procedure if (pivot == -1) throw new Exception("Pivot has not been selected"); // We branch on the pivot, one branch we include the pivot in the IS. // This might possibly disconnect the subgraph G(P + X), thus we set the performDFS boolean to true. count = Compute(graph, p - graph.ClosedNeighborhood(pivot), x - graph.OpenNeighborhood(pivot), true); // One branch we exclude the pivot of the IS. This will not cause the graph to get possibly disconnected count += Compute(graph, p - pivot, x + pivot, false); return count; }
public Dfa(int l) { this.mark = false; this.accept = null; this.anchor = 0; this.nfa_set = null; this.nfa_bit = null; this.label = l; }
private static UNSequence ComputeSequence(Datastructures.Graph graph, BitSet connectedComponent, CandidateStrategy candidateStrategy, int init, ref int max) { int n = graph.Size; List<int> sequence = new List<int>() { init }; BitSet left = new BitSet(0, n, new int[] { init }); BitSet right = connectedComponent - init; // Initially we store the empty set and the set with init as the representative, ie N(init) * right Set<BitSet> unLeft = new Set<BitSet>() { new BitSet(0, n), graph.OpenNeighborhood(init) * right }; int value = int.MinValue; while (!right.IsEmpty) { Set<BitSet> unChosen = new Set<BitSet>(); int chosen = Heuristics.TrivialCases(graph, left, right); if (chosen != -1) { unChosen = IncrementUn(graph, left, unLeft, chosen); } // If chosen has not been set it means that no trivial case was found // Depending on the criteria for the next vertex we call a different algorithm else { BitSet candidates = Heuristics.Candidates(graph, left, right, candidateStrategy); int min = int.MaxValue; foreach (int v in candidates) { Set<BitSet> unV = IncrementUn(graph, left, unLeft, v); if (unV.Count < min) { chosen = v; unChosen = unV; min = unV.Count; } } } // This should never happen if (chosen == -1) throw new Exception("No vertex is chosen for next step in the heuristic"); // Add/remove the next vertex in the appropiate sets sequence.Add(chosen); left += chosen; right -= chosen; unLeft = unChosen; value = Math.Max(unChosen.Count, value); if (value > max) { return new UNSequence() { Sequence = null, Value = int.MaxValue }; } } return new UNSequence() { Sequence = sequence, Value = value }; }
public BinaryReal(BitSet bits, int numberOfBits, double lowerBound, double upperBound) : base(numberOfBits) { Bits = bits.Clone() as BitSet; LowerBound = lowerBound; UpperBound = upperBound; Decode(); }
public TrashedRegisterSummarizer(IProcessorArchitecture arch, Procedure proc, ProcedureFlow pf, SymbolicEvaluationContext ctx) { this.arch = arch; this.proc = proc; this.pf = pf; trashed = arch.CreateRegisterBitset(); preserved = arch.CreateRegisterBitset(); this.ctx = ctx; this.cmp = new ExpressionValueComparer(); }
public void BitSetEmpty() { BitSet a = new BitSet(8); Assert.IsTrue(a.IsEmpty); BitSet b = new BitSet(8); b[7] = true; Assert.IsTrue(!b.IsEmpty); b[7] = false; Assert.IsTrue(b.IsEmpty); }
public void BitSetAllEnumerate() { using (FileUnitTester fut = new FileUnitTester("Core/BitSetAll.txt")) { BitSet a = new BitSet(8); a.SetAll(true); EnumerateBitsetBackwards(a, fut.TextWriter); fut.AssertFilesEqual(); } }
public void BitSetToString() { BitSet b = new BitSet(8); b[0] = true; b[1] = false; b[2] = true; b[7] = true; b[31] = true; string sExp = "10100001"; string s = b.ToString(); Assert.AreEqual(sExp, s); }
public void BitSetAll() { BitSet a = new BitSet(8); a.SetAll(true); string sExp = "11111111"; string s = a.ToString(); Assert.AreEqual(sExp, s); a.SetAll(false); sExp = "00000000"; s = a.ToString(); Assert.AreEqual(sExp, s); }
private static void computeClasses(Spec spec) { SimplifyNfa.original_charset_size = spec.dtrans_ncols; SimplifyNfa.ccls = new char[SimplifyNfa.original_charset_size]; char c = '\u0001'; BitSet bitSet = new BitSet(); BitSet bitSet2 = new BitSet(); Dictionary<char, char> dictionary = new Dictionary<char, char>(); Console.WriteLine("Working on character classes."); for (int i = 0; i < spec.nfa_states.Count; i++) { Nfa nfa = spec.nfa_states[i]; if (nfa.Edge != '�' && nfa.Edge != '') { bitSet.ClearAll(); bitSet2.ClearAll(); for (int j = 0; j < SimplifyNfa.ccls.Length; j++) { if ((int)nfa.Edge == j || (nfa.Edge == '' && nfa.GetCharSet().contains(j))) { bitSet.Set((int)SimplifyNfa.ccls[j], true); } else { bitSet2.Set((int)SimplifyNfa.ccls[j], true); } } bitSet.And(bitSet2); if (bitSet.GetLength() != 0) { dictionary.Clear(); for (int k = 0; k < SimplifyNfa.ccls.Length; k++) { if (bitSet.Get((int)SimplifyNfa.ccls[k]) && ((int)nfa.Edge == k || (nfa.Edge == '' && nfa.GetCharSet().contains(k)))) { char c2 = SimplifyNfa.ccls[k]; if (!dictionary.ContainsKey(c2)) { Dictionary<char, char> arg_14F_0 = dictionary; char arg_14F_1 = c2; char expr_14A = c; c = (char)(expr_14A + '\u0001'); arg_14F_0.Add(arg_14F_1, expr_14A); } SimplifyNfa.ccls[k] = dictionary[c2]; } } } } } SimplifyNfa.mapped_charset_size = (int)c; }
// This constructor returns a new bipartite graph by putting all vertices in 'left' on one side, and 'right' on the other side // There will be an edge between two vertices if there was an edge in the original graph public BipartiteGraph(Graph graph, BitSet left, BitSet right) : this(left, right, left.Count + right.Count) { Dictionary<int, int> mapping = new Dictionary<int, int>(); int i = 0; foreach (int v in Left + Right) mapping[v] = i++; foreach (int v in Left) foreach (int w in graph.OpenNeighborhood(v) * Right) Connect(mapping[v], mapping[w]); }
// Builds a neighborhood for a set X from the ground on up, without relying on what has been saved previously in O(n^2) time public DNeighborhood(BitSet x, BitSet vector, Graph graph) { Vector = vector; _occurrences = new Dictionary<int, int>(); // Loops in O(|Vector|) time over all vertices in the vector foreach (int v in Vector) { // Bitset operation of O(n) time BitSet nv = graph.OpenNeighborhood(v) * x; _occurrences[v] = Math.Min(nv.Count, dValue); } }
public void BitSetClone() { BitSet a = new BitSet(8); a[0] = true; a[2] = true; BitSet b = new BitSet(a); string sExp = "10100000"; string s = b.ToString(); Assert.AreEqual(sExp, s); BitSet c = (BitSet) b.Clone(); s = c.ToString(); Assert.AreEqual(sExp, s); }
private void FillTable(Graph graph, List<int> sequence) { int n = graph.Size; // Processed vertices BitSet left = new BitSet(0, n); // Unprocessed vertices BitSet right = graph.Vertices; // Lists of representatives that we keep track of on each level of the algorithm LinearRepresentativeList reps = new LinearRepresentativeList(); // Initial insertions, the empty set always has the empty neighborhood set as a representative initially reps.Update(new BitSet(0, n), new BitSet(0, n)); for (int i = 0; i < sequence.Count; i++) { /// We give v the possibility to be a representative instead of being contained in neighborhoods int v = sequence[i]; // Actually move v from one set to the other set left += v; right -= v; // We don't want to disturb any pointers so we create new empty datastructures to save everything for the next iteration LinearRepresentativeList nextReps = new LinearRepresentativeList(); // We are iterating over all representatives saved inside the list of the previous step. For each entry there are only two possibilities to create a new neighborhood foreach (BitSet representative in reps) { // Case 1: The neighborhood possibly contained v (thus v has to be removed), but is still valid BitSet neighborhood = reps.GetNeighborhood(representative) - v; nextReps.Update(representative, neighborhood); // Case 2: The union of the old neighborhood, together with v's neighborhood, creates a new entry. The representative is uniond together with v and saved. BitSet representative_ = representative + v; BitSet neighborhood_ = neighborhood + (graph.OpenNeighborhood(v) * right); nextReps.Update(representative_, neighborhood_); } // Update the values for the next iteration reps = nextReps; // Save the maximum size that we encounter during all iterations; this will be the boolean dimension of the graph. MaxDimension = Math.Max(MaxDimension, reps.Count); // Save the representatives at the current cut in the table _table[left] = reps; } }
public ProcedureFlow(Procedure proc, IProcessorArchitecture arch) { this.proc = proc; PreservedRegisters = arch.CreateRegisterBitset(); TrashedRegisters = arch.CreateRegisterBitset(); ConstantRegisters = new Dictionary<Storage, Constant>(); ByPass = arch.CreateRegisterBitset(); MayUse = arch.CreateRegisterBitset(); LiveOut = arch.CreateRegisterBitset(); StackArguments = new Hashtable(); }
/*************************/ // Construction /*************************/ // Constructor for a new graph of size n public Graph(int n) { _adjacencyMatrix = new BitSet[n]; Size = n; List<int> verticesList = new List<int>(); for (int i = 0; i < n; i++) { verticesList.Add(i); _adjacencyMatrix[i] = new BitSet(0, n); } Vertices = new BitSet(0, n, verticesList); }
public virtual IDictionary Remove(string[] keys, BitSet flagMap, string providerName, short onDsItemsRemovedCallback) { return(null); }
internal virtual void PublishMessage(string messageId, object payLoad, long creationTime, long expirationTime, Hashtable metadata, BitSet flagMap) { }
public InsertCommand(string key, byte[] value, CacheDependency dependency, CacheSyncDependency syncDependency, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, short removeCallback, short updateCallback, short dsItemsUpdateCallbackId, bool isResyncExpiredItems, string group, string subGroup, short itemUpdated, bool isAsync, Hashtable queryInfo, BitSet flagMap, object lockId, ulong version, LockAccessType accessType, string providerName, string resyncProviderName, string cacheId, EventDataFilter updateCallbackFilter, EventDataFilter removeCallabackFilter, int methodOverload, string clientId, CallbackType callbackType = Runtime.Events.CallbackType.PushBasedNotification) { base.name = "InsertCommand"; base.asyncCallbackSpecified = isAsync && itemUpdated != -1 ? true : false; base.isAsync = isAsync; base.key = key; _itemUpdated = itemUpdated; _insertCommand = new Alachisoft.NCache.Common.Protobuf.InsertCommand(); _insertCommand.key = key; Alachisoft.NCache.Caching.UserBinaryObject ubObject = UserBinaryObject.CreateUserBinaryObject(value); _insertCommand.data.AddRange(ubObject.DataList); _methodOverload = methodOverload; _insertCommand.requestId = base.RequestId; _insertCommand.removeCallbackId = removeCallback; _insertCommand.updateCallbackId = updateCallback; _insertCommand.updateDataFilter = (short)updateCallbackFilter; _insertCommand.removeDataFilter = (short)removeCallabackFilter; _insertCommand.datasourceUpdatedCallbackId = dsItemsUpdateCallbackId; _insertCommand.isAsync = isAsync; _insertCommand.priority = (int)priority; _insertCommand.flag = flagMap.Data; _insertCommand.itemVersion = version; if (lockId != null) { _insertCommand.lockId = lockId.ToString(); } _insertCommand.lockAccessType = (int)accessType; _insertCommand.providerName = providerName; _insertCommand.resyncProviderName = resyncProviderName; _insertCommand.clientID = clientId; _insertCommand.CallbackType = CallbackType(callbackType); if (syncDependency != null) { _insertCommand.syncDependency = new Alachisoft.NCache.Common.Protobuf.SyncDependency(); _insertCommand.syncDependency.cacheId = syncDependency.CacheId; _insertCommand.syncDependency.key = syncDependency.Key; _insertCommand.syncDependency.server = syncDependency.Server; _insertCommand.syncDependency.port = syncDependency.Port; } if (absoluteExpiration.Equals(Caching.Cache.DefaultAbsolute.ToUniversalTime())) { _insertCommand.absExpiration = 1; } else if (absoluteExpiration.Equals(Caching.Cache.DefaultAbsoluteLonger.ToUniversalTime())) { _insertCommand.absExpiration = 2; } else if (absoluteExpiration != Caching.Cache.NoAbsoluteExpiration) { _insertCommand.absExpiration = absoluteExpiration.Ticks; } if (slidingExpiration.Equals(Caching.Cache.DefaultSliding)) { _insertCommand.sldExpiration = 1; } else if (slidingExpiration.Equals(Caching.Cache.DefaultSlidingLonger)) { _insertCommand.sldExpiration = 2; } else if (slidingExpiration != Caching.Cache.NoSlidingExpiration) { _insertCommand.sldExpiration = slidingExpiration.Ticks; } _insertCommand.isResync = isResyncExpiredItems; _insertCommand.group = group; _insertCommand.subGroup = subGroup; ObjectQueryInfo objectQueryInfo = new ObjectQueryInfo(); if (queryInfo["query-info"] != null) { objectQueryInfo.queryInfo = ProtobufHelper.GetQueryInfoObj(queryInfo["query-info"] as Hashtable); } if (queryInfo["tag-info"] != null) { objectQueryInfo.tagInfo = ProtobufHelper.GetTagInfoObj(queryInfo["tag-info"] as Hashtable); } if (queryInfo["named-tag-info"] != null) { objectQueryInfo.namedTagInfo = ProtobufHelper.GetNamedTagInfoObj(queryInfo["named-tag-info"] as Hashtable, true); } _insertCommand.objectQueryInfo = objectQueryInfo; if (dependency != null) { _insertCommand.dependency = Alachisoft.NCache.Common.Util.DependencyHelper.GetProtoBufDependency(dependency); } }
public virtual object GetCacheItem(string key, BitSet flagMap, string group, string subGroup, ref CacheItemVersion version, ref LockHandle lockHandle, TimeSpan lockTimeout, LockAccessType accessType, string providerName) { return(null); }
public virtual CacheItemVersion Insert(string key, object value, CacheDependency dependency, CacheSyncDependency syncDependency, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, short onRemoveCallback, short onUpdateCallback, short onDsItemUpdatedCallback, bool isResyncExpiredItems, string group, string subGroup, Hashtable queryInfo, BitSet flagMap, object lockId, CacheItemVersion version, LockAccessType accessType, string providerName, string resyncProviderName, EventDataFilter updateCallbackFilter, EventDataFilter removeCallabackFilter, long size, string clientId, CallbackType callbackType = CallbackType.PushBasedNotification) { return(null); }
public virtual CompressedValueEntry Remove(string key, BitSet flagMap, short dsItemRemovedCallbackId, object lockId, CacheItemVersion version, LockAccessType accessType, string ProviderName) { return(null); }
public virtual void Delete(string key, BitSet flagMap, short dsItemRemovedCallbackId, object lockId, CacheItemVersion version, LockAccessType accessType, string ProviderName) { }
public void Kill(Actor self, Actor attacker, BitSet<DamageType> damageTypes) { InflictDamage(self, attacker, new Damage(MaxHP, damageTypes), true); }
private static void CheckDependencies(IList <System.Tuple <RuleDependencyAttribute, ICustomAttributeProvider> > dependencies, Type recognizerType) { string[] ruleNames = GetRuleNames(recognizerType); int[] ruleVersions = GetRuleVersions(recognizerType, ruleNames); RuleDependencyChecker.RuleRelations relations = ExtractRuleRelations(recognizerType); StringBuilder errors = new StringBuilder(); foreach (System.Tuple <RuleDependencyAttribute, ICustomAttributeProvider> dependency in dependencies) { if (!dependency.Item1.Recognizer.GetTypeInfo().IsAssignableFrom(recognizerType)) { continue; } // this is the rule in the dependency set with the highest version number int effectiveRule = dependency.Item1.Rule; if (effectiveRule < 0 || effectiveRule >= ruleVersions.Length) { string message = string.Format("Rule dependency on unknown rule {0}@{1} in {2}", dependency.Item1.Rule, dependency.Item1.Version, dependency.Item1.Recognizer.ToString()); errors.AppendLine(dependency.Item2.ToString()); errors.AppendLine(message); continue; } Dependents dependents = Dependents.Self | dependency.Item1.Dependents; ReportUnimplementedDependents(errors, dependency, dependents); BitSet @checked = new BitSet(); int highestRequiredDependency = CheckDependencyVersion(errors, dependency, ruleNames, ruleVersions, effectiveRule, null); if ((dependents & Dependents.Parents) != 0) { BitSet parents = relations.parents[dependency.Item1.Rule]; for (int parent = parents.NextSetBit(0); parent >= 0; parent = parents.NextSetBit(parent + 1)) { if (parent < 0 || parent >= ruleVersions.Length || @checked.Get(parent)) { continue; } @checked.Set(parent); int required = CheckDependencyVersion(errors, dependency, ruleNames, ruleVersions, parent, "parent"); highestRequiredDependency = Math.Max(highestRequiredDependency, required); } } if ((dependents & Dependents.Children) != 0) { BitSet children = relations.children[dependency.Item1.Rule]; for (int child = children.NextSetBit(0); child >= 0; child = children.NextSetBit(child + 1)) { if (child < 0 || child >= ruleVersions.Length || @checked.Get(child)) { continue; } @checked.Set(child); int required = CheckDependencyVersion(errors, dependency, ruleNames, ruleVersions, child, "child"); highestRequiredDependency = Math.Max(highestRequiredDependency, required); } } if ((dependents & Dependents.Ancestors) != 0) { BitSet ancestors = relations.GetAncestors(dependency.Item1.Rule); for (int ancestor = ancestors.NextSetBit(0); ancestor >= 0; ancestor = ancestors.NextSetBit(ancestor + 1)) { if (ancestor < 0 || ancestor >= ruleVersions.Length || @checked.Get(ancestor)) { continue; } @checked.Set(ancestor); int required = CheckDependencyVersion(errors, dependency, ruleNames, ruleVersions, ancestor, "ancestor"); highestRequiredDependency = Math.Max(highestRequiredDependency, required); } } if ((dependents & Dependents.Descendants) != 0) { BitSet descendants = relations.GetDescendants(dependency.Item1.Rule); for (int descendant = descendants.NextSetBit(0); descendant >= 0; descendant = descendants.NextSetBit(descendant + 1)) { if (descendant < 0 || descendant >= ruleVersions.Length || @checked.Get(descendant)) { continue; } @checked.Set(descendant); int required = CheckDependencyVersion(errors, dependency, ruleNames, ruleVersions, descendant, "descendant"); highestRequiredDependency = Math.Max(highestRequiredDependency, required); } } int declaredVersion = dependency.Item1.Version; if (declaredVersion > highestRequiredDependency) { string message = string.Format("Rule dependency version mismatch: {0} has maximum dependency version {1} (expected {2}) in {3}", ruleNames[dependency.Item1.Rule], highestRequiredDependency, declaredVersion, dependency.Item1.Recognizer.ToString()); errors.AppendLine(dependency.Item2.ToString()); errors.AppendLine(message); } } if (errors.Length > 0) { throw new InvalidOperationException(errors.ToString()); } }
public override void ReportAmbiguity(Antlr4.Runtime.Parser recognizer, DFA dfa, int startIndex, int stopIndex, bool exact, BitSet ambigAlts, ATNConfigSet configs) { }
void INotifyCrushed.WarnCrush(Actor self, Actor crusher, BitSet <CrushClass> crushClasses) { }
public virtual void RemoveAsync(string key, BitSet flagMap, short onDsItemRemovedCallback) { }
public InsertCommand(string key, byte[] value, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, short removeCallback, short updateCallback, short dsItemsUpdateCallbackId, bool isResyncExpiredItems, short itemUpdated, bool isAsync, Hashtable queryInfo, BitSet flagMap, object lockId, ulong version, LockAccessType accessType, string providerName, string resyncProviderName, bool encryption, string cacheId, EventDataFilter updateCallbackFilter, EventDataFilter removeCallabackFilter, int methodOverload, string clientId, string typeName, CallbackType callbackType = Runtime.Events.CallbackType.PushBasedNotification) { base.name = "InsertCommand"; base.asyncCallbackSpecified = isAsync && itemUpdated != -1 ? true : false; base.isAsync = isAsync; base.key = key; _itemUpdated = itemUpdated; _insertCommand = new Alachisoft.NCache.Common.Protobuf.InsertCommand(); _insertCommand.key = key; Alachisoft.NCache.Common.Caching.UserBinaryObject ubObject = Alachisoft.NCache.Common.Caching.UserBinaryObject.CreateUserBinaryObject(value); _insertCommand.data.AddRange(ubObject.DataList); _methodOverload = methodOverload; _insertCommand.requestId = base.RequestId; _insertCommand.removeCallbackId = removeCallback; _insertCommand.updateCallbackId = updateCallback; _insertCommand.updateDataFilter = (short)updateCallbackFilter; _insertCommand.removeDataFilter = (short)removeCallabackFilter; _insertCommand.datasourceUpdatedCallbackId = dsItemsUpdateCallbackId; _insertCommand.isAsync = isAsync; _insertCommand.priority = (int)priority; _insertCommand.flag = flagMap.Data; _insertCommand.itemVersion = version; if (lockId != null) { _insertCommand.lockId = lockId.ToString(); } _insertCommand.lockAccessType = (int)accessType == 0 ? (int)LockAccessType.IGNORE_LOCK : (int)accessType; _insertCommand.providerName = providerName; _insertCommand.resyncProviderName = resyncProviderName; // Client ID: Must not have value except ClientCache. _insertCommand.clientID = clientId; _insertCommand.CallbackType = CallbackType(callbackType); if (absoluteExpiration.Equals(Cache.DefaultAbsolute.ToUniversalTime())) { _insertCommand.absExpiration = 1; } else if (absoluteExpiration.Equals(Cache.DefaultAbsoluteLonger.ToUniversalTime())) { _insertCommand.absExpiration = 2; } else if (absoluteExpiration != Cache.NoAbsoluteExpiration) { _insertCommand.absExpiration = absoluteExpiration.Ticks; } if (slidingExpiration.Equals(Cache.DefaultSliding)) { _insertCommand.sldExpiration = 1; } else if (slidingExpiration.Equals(Cache.DefaultSlidingLonger)) { _insertCommand.sldExpiration = 2; } else if (slidingExpiration != Cache.NoSlidingExpiration) { _insertCommand.sldExpiration = slidingExpiration.Ticks; } _insertCommand.isResync = isResyncExpiredItems; }
/// <exception cref="IOException"/> public virtual void ProcessClass(ClassesProcessor.ClassNode node) { foreach (ClassesProcessor.ClassNode child in node.nested) { ProcessClass(child); } ClassesProcessor clProcessor = DecompilerContext.GetClassProcessor(); StructClass cl = node.classStruct; if (cl.GetBytecodeVersion() < ICodeConstants.Bytecode_Java_8) { // lambda beginning with Java 8 return; } StructBootstrapMethodsAttribute bootstrap = cl.GetAttribute(StructGeneralAttribute .Attribute_Bootstrap_Methods); if (bootstrap == null || bootstrap.GetMethodsNumber() == 0) { return; } // no bootstrap constants in pool BitSet lambda_methods = new BitSet(); // find lambda bootstrap constants for (int i = 0; i < bootstrap.GetMethodsNumber(); ++i) { LinkConstant method_ref = bootstrap.GetMethodReference(i); // method handle // FIXME: extend for Eclipse etc. at some point if (Javac_Lambda_Class.Equals(method_ref.classname) && (Javac_Lambda_Method.Equals (method_ref.elementname) || Javac_Lambda_Alt_Method.Equals(method_ref.elementname ))) { lambda_methods.Set(i); } } if (lambda_methods.IsEmpty()) { return; } // no lambda bootstrap constant found Dictionary <string, string> mapMethodsLambda = new Dictionary <string, string>(); // iterate over code and find invocations of bootstrap methods. Replace them with anonymous classes. foreach (StructMethod mt in cl.GetMethods()) { mt.ExpandData(); InstructionSequence seq = mt.GetInstructionSequence(); if (seq != null && seq.Length() > 0) { int len = seq.Length(); for (int i = 0; i < len; ++i) { Instruction instr = seq.GetInstr(i); if (instr.opcode == ICodeConstants.opc_invokedynamic) { LinkConstant invoke_dynamic = cl.GetPool().GetLinkConstant(instr.Operand(0)); if (lambda_methods.Get(invoke_dynamic.index1)) { // lambda invocation found List <PooledConstant> bootstrap_arguments = bootstrap.GetMethodArguments(invoke_dynamic .index1); MethodDescriptor md = MethodDescriptor.ParseDescriptor(invoke_dynamic.descriptor); string lambda_class_name = md.ret.value; string lambda_method_name = invoke_dynamic.elementname; string lambda_method_descriptor = ((PrimitiveConstant)bootstrap_arguments[2]).GetString (); // method type LinkConstant content_method_handle = (LinkConstant)bootstrap_arguments[1]; ClassesProcessor.ClassNode node_lambda = new ClassesProcessor.ClassNode(content_method_handle .classname, content_method_handle.elementname, content_method_handle.descriptor, content_method_handle.index1, lambda_class_name, lambda_method_name, lambda_method_descriptor , cl); node_lambda.simpleName = cl.qualifiedName + "##Lambda_" + invoke_dynamic.index1 + "_" + invoke_dynamic.index2; node_lambda.enclosingMethod = InterpreterUtil.MakeUniqueKey(mt.GetName(), mt.GetDescriptor ()); node.nested.Add(node_lambda); node_lambda.parent = node; Sharpen.Collections.Put(clProcessor.GetMapRootClasses(), node_lambda.simpleName, node_lambda); if (!node_lambda.lambdaInformation.is_method_reference) { Sharpen.Collections.Put(mapMethodsLambda, node_lambda.lambdaInformation.content_method_key , node_lambda.simpleName); } } } } } mt.ReleaseResources(); } // build class hierarchy on lambda foreach (ClassesProcessor.ClassNode nd in node.nested) { if (nd.type == ClassesProcessor.ClassNode.Class_Lambda) { string parent_class_name = mapMethodsLambda.GetOrNull(nd.enclosingMethod); if (parent_class_name != null) { ClassesProcessor.ClassNode parent_class = clProcessor.GetMapRootClasses().GetOrNull (parent_class_name); parent_class.nested.Add(nd); nd.parent = parent_class; } } } }
internal virtual Hashtable InvokeEntryProcessor(string[] keys, IEntryProcessor entryProcessor, string readThruProviderName, BitSet dsReadOptionFlag, string writeThruProviderName, BitSet dsWriteOptionFlag, params object[] arguments) { return(null); }
public virtual object SafeSerialize(object serializableObject, string serializationContext, ref BitSet flag, CacheImplBase cacheImpl, ref long size) { return(null); }
public virtual object SafeDeserialize(object serializedObject, string serializationContext, BitSet flag, CacheImplBase cacheImpl) { return(null); }
/// <summary> /// Cria a instancia com os valores iniciais. /// </summary> /// <param name="key"></param> /// <param name="value"></param> /// <param name="dependency"></param> /// <param name="syncDependency"></param> /// <param name="expiration"></param> /// <param name="options"></param> /// <param name="itemRemovedCallback"></param> /// <param name="group"></param> /// <param name="subgroup"></param> /// <param name="queryInfo"></param> /// <param name="Flag"></param> /// <param name="lockId"></param> /// <param name="version"></param> /// <param name="accessType"></param> /// <param name="providername"></param> /// <param name="resyncProviderName"></param> public CompactCacheEntry(object key, object value, ExpirationHint dependency, CacheSyncDependency syncDependency, long expiration, byte options, object itemRemovedCallback, string group, string subgroup, Hashtable queryInfo, BitSet Flag, object lockId, ulong version, LockAccessType accessType, string providername, string resyncProviderName) { _key = key; _flag = Flag; _value = value; _dependency = dependency; _syncDependency = syncDependency; _expiration = expiration; _options = options; _itemRemovedCallback = itemRemovedCallback; if (group != null) { _group = group; if (subgroup != null) { _subgroup = subgroup; } } _queryInfo = queryInfo; _lockId = lockId; _accessType = accessType; _version = version; _providerName = providername; _resyncProviderName = resyncProviderName; }
public virtual void InsertAsync(string key, object value, CacheDependency dependency, CacheSyncDependency syncDependency, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, short onRemoveCallback, short onUpdateCallback, short onAsyncItemUpdateCallback, short onDsItemUpdatedCallback, bool isResyncExpiredItems, string group, string subGroup, Hashtable queryInfo, BitSet flagMap, string providerName, string resyncProviderName, EventDataFilter updateCallbackFilter, EventDataFilter removeCallbackFilter, long size, string clientId) { }
public virtual IDictionary Get(string[] keys, BitSet flagMap, string providerName) { return(null); }
public virtual void Clear(BitSet flagMap, short onDsClearedCallback, string providerName) { }
void IBridgeSegment.Demolish(Actor saboteur, BitSet <DamageType> damageTypes) { // Do nothing }
internal virtual object GetMessageData(BitSet flagMap) { return(null); }
public override void ReportAttemptingFullContext(Parser recognizer, DFA dfa, int startIndex, int stopIndex, BitSet conflictingAlts, SimulatorState conflictState) { }
public virtual void ClearAsync(BitSet flagMap, short onAsyncCacheClearCallback, short onDsClearedCallback, string providerName) { }
public virtual void Delete(string[] keys, BitSet flagMap, string providerName, short onDsItemsRemovedCallback) { }
/// <exception cref="System.Exception"/> public virtual void TestFormat() { Job job = Job.GetInstance(conf); FileSystem fs = FileSystem.GetLocal(conf); Path dir = new Path(Runtime.GetProperty("test.build.data", ".") + "/mapred"); Path file = new Path(dir, "test.seq"); int seed = new Random().Next(); Random random = new Random(seed); fs.Delete(dir, true); FileInputFormat.SetInputPaths(job, dir); // for a variety of lengths for (int length = 0; length < MaxLength; length += random.Next(MaxLength / 10) + 1) { // create a file with length entries SequenceFile.Writer writer = SequenceFile.CreateWriter(fs, conf, file, typeof(IntWritable ), typeof(LongWritable)); try { for (int i = 0; i < length; i++) { IntWritable key = new IntWritable(i); LongWritable value = new LongWritable(10 * i); writer.Append(key, value); } } finally { writer.Close(); } TaskAttemptContext context = MapReduceTestUtil.CreateDummyMapTaskAttemptContext(job .GetConfiguration()); // try splitting the file in a variety of sizes InputFormat <Text, Text> format = new SequenceFileAsTextInputFormat(); for (int i_1 = 0; i_1 < 3; i_1++) { // check each split BitSet bits = new BitSet(length); int numSplits = random.Next(MaxLength / (SequenceFile.SyncInterval / 20)) + 1; FileInputFormat.SetMaxInputSplitSize(job, fs.GetFileStatus(file).GetLen() / numSplits ); foreach (InputSplit split in format.GetSplits(job)) { RecordReader <Text, Text> reader = format.CreateRecordReader(split, context); MapContext <Text, Text, Text, Text> mcontext = new MapContextImpl <Text, Text, Text , Text>(job.GetConfiguration(), context.GetTaskAttemptID(), reader, null, null, MapReduceTestUtil.CreateDummyReporter(), split); reader.Initialize(split, mcontext); Type readerClass = reader.GetType(); NUnit.Framework.Assert.AreEqual("reader class is SequenceFileAsTextRecordReader." , typeof(SequenceFileAsTextRecordReader), readerClass); Text key; try { int count = 0; while (reader.NextKeyValue()) { key = reader.GetCurrentKey(); int keyInt = System.Convert.ToInt32(key.ToString()); NUnit.Framework.Assert.IsFalse("Key in multiple partitions.", bits.Get(keyInt)); bits.Set(keyInt); count++; } } finally { reader.Close(); } } NUnit.Framework.Assert.AreEqual("Some keys in no partition.", length, bits.Cardinality ()); } } }
protected override object RecoverFromMismatchedToken(IIntStream input, int ttype, BitSet follow) { throw new MismatchedTokenException(ttype, input); }
/// <exception cref="IOException"/> public ConstantPool(DataInputStream @in) { int size = @in.ReadUnsignedShort(); pool = new List <PooledConstant>(size); BitSet[] nextPass = new BitSet[] { new BitSet(size), new BitSet(size), new BitSet (size) }; // first dummy constant pool.Add(null); // first pass: read the elements for (int i = 1; i < size; i++) { byte tag = unchecked ((byte)@in.ReadUnsignedByte()); switch (tag) { case ICodeConstants.CONSTANT_Utf8: { pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Utf8, @in.ReadUTF())); break; } case ICodeConstants.CONSTANT_Integer: { pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Integer, (@in.ReadInt ()))); break; } case ICodeConstants.CONSTANT_Float: { pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Float, @in.ReadFloat())); break; } case ICodeConstants.CONSTANT_Long: { pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Long, @in.ReadLong())); pool.Add(null); i++; break; } case ICodeConstants.CONSTANT_Double: { pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Double, @in.ReadDouble())); pool.Add(null); i++; break; } case ICodeConstants.CONSTANT_Class: case ICodeConstants.CONSTANT_String: case ICodeConstants.CONSTANT_MethodType: { pool.Add(new PrimitiveConstant(tag, @in.ReadUnsignedShort())); nextPass[0].Set(i); break; } case ICodeConstants.CONSTANT_NameAndType: { pool.Add(new LinkConstant(tag, @in.ReadUnsignedShort(), @in.ReadUnsignedShort())); nextPass[0].Set(i); break; } case ICodeConstants.CONSTANT_Fieldref: case ICodeConstants.CONSTANT_Methodref: case ICodeConstants.CONSTANT_InterfaceMethodref: case ICodeConstants.CONSTANT_InvokeDynamic: { pool.Add(new LinkConstant(tag, @in.ReadUnsignedShort(), @in.ReadUnsignedShort())); nextPass[1].Set(i); break; } case ICodeConstants.CONSTANT_MethodHandle: { pool.Add(new LinkConstant(tag, @in.ReadUnsignedByte(), @in.ReadUnsignedShort())); nextPass[2].Set(i); break; } } } // resolving complex pool elements foreach (BitSet pass in nextPass) { int idx = 0; while ((idx = pass.NextSetBit(idx + 1)) > 0) { pool[idx].ResolveConstant(this); } } // get global constant pool interceptor instance, if any available interceptor = DecompilerContext.GetPoolInterceptor(); }
public virtual void RemoveAsync(string key, BitSet flagMap, short onAsyncItemRemoveCallback, short onDsItemRemovedCallback, string providerName) { }