/// <summary>Computes the equivalent inverted set, e.g. if the set is /// <c>'b'..'y'</c>, the equivalent inverted set is /// <c>~(int.MinValue..'a' | 'z'..int.MaxValue)</c>.</summary> public IntSet EquivalentInverted() { if (_ranges.Count == 0) { return(new IntSet(new IntRange(int.MinValue, int.MaxValue), IsCharSet, !IsInverted)); } var ranges = new InternalList <IntRange>(_ranges.Count + 1); int lowest = _ranges[0].Lo, highest = _ranges[_ranges.Count - 1].Hi; if (lowest > int.MinValue) { ranges.Add(new IntRange(int.MinValue, _ranges[0].Lo - 1)); } for (int i = 1; i < _ranges.Count; i++) { var r = new IntRange(_ranges[i - 1].Hi + 1, _ranges[i].Lo - 1); Debug.Assert(r.Lo <= r.Hi); ranges.Add(r); } if (highest < int.MaxValue) { ranges.Add(new IntRange(highest + 1, int.MaxValue)); } return(new IntSet(IsCharSet, ranges, !IsInverted, false)); }
public void Evaluate() { var list = new InternalList(); list.Add("value", Arguments[0]); list.Add("position", Arguments[1]); list.Add("length", Arguments[2]); Array(variableName).Add(list); }
public void Evaluate() { var list = new InternalList(); list.Add("value", Arguments[0]); list.Add("position", Arguments[1]); list.Add("length", Arguments[2]); Regions[variableName] = list; }
public bool MoveNext() { for (;;) { var child = _frame; int result = _frame.MoveNext(ref child, ref _current); if (result == 1) { return(true); } if (result == 0) { // if possible, pop a frame off the stack and continue if (_stack.IsEmpty) { return(false); } _frame = _stack.Last; _stack.Pop(); } else { // push child frame and continue _stack.Add(_frame); _frame = child; } } }
public ConcurrentContentList(IEnumerable <ContentItem> init) { foreach (var i in init) { InternalList.Add(i); } }
/// <summary> /// Decodes a ASN.1-encoded byte array that contains revoked certificate information to a collection. /// </summary> /// <param name="asn">ASN.1 that points to the beginning of the CRL entry collection structure.</param> /// <exception cref="Asn1InvalidTagException">The encoded data is not valid.</exception> /// <exception cref="ArgumentNullException">The <strong>rawData</strong> parameter is null reference.</exception> /// <remarks>This method removes any existing entries in the collection before decoding.</remarks> public void Decode(Asn1Reader asn) { if (asn == null) { throw new ArgumentNullException(nameof(asn)); } if (asn.Tag != 48) { throw new Asn1InvalidTagException(asn.Offset); } Int32 offset = asn.Offset; InternalList.Clear(); InternalList.Capacity = asn.GetNestedNodeCount(); if (!asn.MoveNext()) { throw new Asn1InvalidTagException(asn.Offset); } do { InternalList.Add(new X509CRLEntry(asn)); } while (asn.MoveNextSibling()); asn.Seek(offset); }
/// <summary> /// Decodes ASN.1 encoded byte array to an array of <see cref="X500RdnAttribute"/> objects. /// </summary> /// <param name="rawData">ASN.1-encoded byte array.</param> /// <exception cref="ArgumentNullException"> /// <strong>rawData</strong> parameter is null. /// </exception> /// <exception cref="AccessViolationException"> /// The collection is read-only and cannot be modified. /// </exception> /// <exception cref="Asn1InvalidTagException"> /// The data in the <strong>rawData</strong> parameter is not valid array of <see cref="X500RdnAttribute"/> objects. /// </exception> public void Decode(Byte[] rawData) { if (IsReadOnly) { throw new AccessViolationException("An object is encoded and is write-protected."); } if (rawData == null) { throw new ArgumentNullException(nameof(rawData)); } InternalList.Clear(); Asn1Reader asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new Asn1InvalidTagException(asn.Offset); } asn.MoveNext(); do { if (asn.Tag != 49) { throw new Asn1InvalidTagException(asn.Offset); } InternalList.Add(new X500RdnAttribute(asn.GetPayload())); } while (asn.MoveNextCurrentLevel()); // reverse list to get attributes from leaf to root. InternalList.Reverse(); }
protected void Reset(CharSource source, ILineColumnFile startingPos = null) { _source = source; _lineOffsets = InternalList <int> .Empty; _lineOffsets.Add(0); _startingPos = startingPos; }
/// <summary>Searches a list of expressions/statements for one or more /// patterns, and performs replacements.</summary> /// <param name="stmts">A list of expressions/statements in which to search.</param> /// <param name="patterns">Each pair consists of (A) something to search /// for and (B) a replacement expression. Part A can use the substitution /// operator with an identifier inside (e.g. $Foo) to "capture" any /// subexpression, and part B can use the same substitution (e.g. $Foo) /// to insert the captured subexpression(s) into the output.</param> /// <param name="replacementCount">Number of replacements that occurred.</param> /// <returns>The result of applying the replacements.</returns> /// <remarks><see cref="LNodeExt.MatchesPattern"/> is used for matching.</remarks> public static VList <LNode> Replace(VList <LNode> stmts, Pair <LNode, LNode>[] patterns, out int replacementCount) { // This list is used to support simple token replacement in TokenTrees _tokenTreeRepls = InternalList <Triplet <Symbol, LNode, int> > .Empty; foreach (var pair in patterns) // Look for Id => Id or Id => Literal { if (pair.A.IsId && (pair.B.IsId || pair.B.IsLiteral)) { _tokenTreeRepls.Add(new Triplet <Symbol, LNode, int>(pair.A.Name, pair.B, 0)); } } // Scan the syntax tree for things to replace... int count = 0; var temp = new MMap <Symbol, LNode>(); var output = stmts.SmartSelect(stmt => stmt.ReplaceRecursive(n => { LNode r = TryReplaceHere(n, patterns, temp); if (r != null) { count++; } return(r); })); replacementCount = count; return(output); }
private void UpdateSlashDivs(bool slashJoined, int boundary, bool append, Alts bAlts) { //Debug.Assert(boundary > 0 && boundary < Arms.Count); //not true when joining with error branch Division prev = _divisions.LastOrDefault(); var bDivs = bAlts != null ? bAlts._divisions : InternalList <Division> .Empty; if (append) { bDivs = Adjust(bDivs, boundary, true); _divisions.AddRange(bDivs); } else { prev = bAlts != null?bAlts._divisions.LastOrDefault() : default(Division); Adjust(_divisions, boundary, false); _divisions.InsertRange(0, bDivs); } var newDiv = new Division { Left = 0, Mid = (short)boundary, Right = (short)Arms.Count, Slash = slashJoined }; _divisions.Add(newDiv); }
/// <summary>Enumerates the underlying sequence.</summary> public IEnumerator <T> GetEnumerator() { if (_e != null) { var top = _e; for (InternalList <IEnumerator <Co <T> > > stack = InternalList <IEnumerator <Co <T> > > .Empty; ;) { while (top.MoveNext()) { var next = top.Current; if (next._e != null) { stack.Add(top); top = next._e; } else { yield return(next._value); } } if (stack.IsEmpty) { break; } top = stack.Last; stack.Pop(); } } else { yield return(_value); } }
public void Add(Symbol item) { if (!Contains(item)) { _bloom.Add(item); _list.Add(item); } }
public override void Add(T item) { if (Contains(item)) { throw new ArgumentException("This item already exists in the inventory!"); } InternalList.Add(item); OnAdded(item); }
private void AutoAddBranchForAndPred(ref InternalList <PredictionBranch> children, AndPred andPred, List <KthSet> alts, Set <AndPred> matched, MSet <AndPred> falsified) { if (!falsified.Contains(andPred)) { var innerMatched = matched.With(andPred); var result = new PredictionBranch(new Set <AndPred>().With(andPred), ComputeAssertionTree2(alts, innerMatched)); falsified.Add(andPred); RemoveFalsifiedCases(alts, falsified); children.Add(result); } }
private int ReadNextLine(int index) { if (AdvanceAfterNextNewline(ref index)) { _lineOffsets.Add(index); } else { _offsetsComplete = true; } return(index); }
/// <summary> /// Adds an <see cref="X509CTLEntry"/> object to the <see cref="X509CTLEntryCollection"/> object. /// </summary> /// <param name="entry">The <see cref="X509CTLEntry"/> object to add to the collection.</param> /// <exception cref="AccessViolationException">The collection is closed and is read-only.</exception> /// <returns>The index of the added <see cref="X509CTLEntry"/> object.</returns> /// <remarks> /// Use this method to add an <see cref="X509CTLEntry"/> object to an existing collection at the current location. /// <para>The method returns a '-1' value if the object is already in the collection.</para> /// </remarks> public override void Add(X509CTLEntry entry) { if (IsReadOnly) { throw new AccessViolationException(Error.E_COLLECTIONCLOSED); } if (InternalList.Contains(entry)) { return; } InternalList.Add(entry); }
static IListSource <Token> ReclassifyTokens(IListSource <Token> oldList) { // Only reclassifies tokens on the current level. Child tokens are untouched. InternalList <Token> newList = new InternalList <Token>(oldList.Count); int c = oldList.Count; for (int i = 0; i < c;) { newList.Add(Reclassify(oldList, ref i)); } return(newList); }
private static InternalList <Symbol> KindAttrTable() { Debug.Assert(((int)TokenKind.KindMask & ((2 << TokenKindShift) - 1)) == (1 << TokenKindShift)); int incr = (1 << TokenKindShift), stopAt = (int)TokenKind.KindMask; var table = new InternalList <Symbol>(stopAt / incr); for (int kind = 0; kind < stopAt; kind += incr) { string kindStr = ((TokenKind)kind).ToString(); table.Add((Symbol)kindStr); } return(table); }
internal bool AddObserver(IAListTreeObserver <K, T> observer) { for (int i = 0; i < _observers.Count; i++) { if (observer == _observers[i]) { return(false); } } observer.DoAttach(_root, _list); _observers.Add(observer); return(true); }
/// <summary> /// Add an item to this collection. /// </summary> /// <param name="newItem"> /// New item to be added to collection /// </param> /// <returns> /// Zero-based index where the new item is added. /// </returns> /// <exception cref="ArgumentException"> /// CompositeCollection can only accept CollectionContainers it doesn't already have. /// </exception> public int Add(object newItem) { CollectionContainer cc = newItem as CollectionContainer; if (cc != null) { AddCollectionContainer(cc); } int addedIndex = InternalList.Add(newItem); OnCollectionChanged(NotifyCollectionChangedAction.Add, newItem, addedIndex); return(addedIndex); }
private static IEnumerator <IntRange> AddAndMoveNext(ref InternalList <IntRange> result, IntRange r, IEnumerator <IntRange> e) { IntRange last; if (result.Count > 0 && (last = result.Last).CanMerge(r)) { result.Last = last.Merged(r); } else { result.Add(r); } return(e.MoveNext() ? e : null); }
public override Value Evaluate() { var stack = State.Stack; var y = stack.Pop(true, LOCATION); InternalList list; if (stack.IsEmpty) { if (y.Type == ValueType.Nil) { return(y); } list = new InternalList(); list.Add(y); return(list); } var x = stack.Pop(true, LOCATION); if (y.Type == ValueType.Nil) { return(x); } list = x as InternalList; if (list != null) { list.Add(y); return(list); } list = new InternalList(); list.Add(x); list.Add(y); return(list); }
/// <summary> /// Decodes ASN.1 encoded byte array to an array of <see cref="X509PolicyQualifier"/> objects. /// </summary> /// <param name="rawData">ASN.1-encoded byte array.</param> /// <exception cref="Asn1InvalidTagException"> /// The data in the <strong>rawData</strong> parameter is not valid array of <see cref="X509PolicyQualifier"/> objects. /// </exception> public void Decode(Byte[] rawData) { InternalList.Clear(); Asn1Reader asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new Asn1InvalidTagException(asn.Offset); } asn.MoveNext(); do { InternalList.Add(new X509PolicyQualifier(asn.GetTagRawData())); } while (asn.MoveNextCurrentLevel()); }
//-------------------------------------------------------------------- // // Public Methods // //--------------------------------------------------------------------- #region Public Methods /// <summary> /// Append a new PageContent to end of this collection /// </summary> /// <param name="newPageContent">New PageContent to be appended</param> /// <returns>The index this new PageContent is appended at</returns> /// <exception cref="ArgumentNullException"> /// Thrown if the argument is null /// </exception> /// <exception cref="InvalidOperationException"> /// Thrown if the page has been added to a PageContentCollection previously /// </exception> public int Add(PageContent newPageContent) { if (newPageContent == null) { throw new ArgumentNullException("newPageContent"); } _logicalParent.AddLogicalChild(newPageContent); InternalList.Add(newPageContent); int index = InternalList.Count - 1; _logicalParent.OnPageContentAppended(index); return(index); }
public virtual void AddRange(IEnumerable <T> collection) { var collectionArray = collection.ToArray(); var dotNetList = InternalList as List <T>; if (dotNetList != null) { dotNetList.AddRange(collectionArray); } else { foreach (var item in collectionArray) { InternalList.Add(item); } } ObservationWindow.NotifyItemsAdded(collectionArray, Enumerable.Range(InternalList.Count - collectionArray.Length, collectionArray.Length)); }
/// <summary> /// Adds an <see cref="X509CertificatePolicy"/> object to the <see cref="X509CertificatePolicyCollection"/> object. /// </summary> /// <remarks>Use this method to add an <see cref="X509CertificatePolicy"/> object to an existing collection at the current location.</remarks> /// <param name="entry">The <see cref="X509CertificatePolicy"/> object to add to the collection.</param> /// <returns> /// The index of the added <see cref="X509CertificatePolicy"/> object. /// <para> /// If the method return a negative number (-1), then collection already contains a duplicated policy OID. /// Duplicated OIDs are not allowed. /// </para> /// </returns> /// <exception cref="AccessViolationException">The collection is closed and is read-only.</exception> public override void Add(X509CertificatePolicy entry) { if (IsReadOnly) { throw new AccessViolationException(Error.E_COLLECTIONCLOSED); } if (entry == null) { throw new ArgumentNullException(nameof(entry)); } if (InternalList.Any(item => item.PolicyOid.Value == entry.PolicyOid.Value)) { return; } InternalList.Add(entry); }
/// <summary> /// Decodes ASN.1-encoded algorithm identifier collection. /// </summary> /// <param name="rawData">ASN.1-encoded byte array that represents algorithm identifier collection.</param> /// <exception cref="ArgumentNullException"> /// <strong>rawData</strong> parameter is null. /// </exception> public void Decode(Byte[] rawData) { if (rawData == null) { throw new ArgumentNullException(nameof(rawData)); } Clear(); var asn = new Asn1Reader(rawData); if (asn.PayloadLength == 0) { return; } asn.MoveNext(); do { InternalList.Add(new AlgorithmIdentifier(asn.GetTagRawData())); } while (asn.MoveNextCurrentLevel()); }
/// <summary>Searches a list of expressions/statements for one or more /// patterns, and performs replacements.</summary> /// <param name="stmts">A list of expressions/statements in which to search.</param> /// <param name="patterns">Each pair consists of (A) something to search /// for and (B) a replacement expression. Part A can use the substitution /// operator with an identifier inside (e.g. $Foo) to "capture" any /// subexpression, and part B can use the same substitution (e.g. $Foo) /// to insert the captured subexpression(s) into the output.</param> /// <param name="replacementCount">Number of replacements that occurred.</param> /// <returns>The result of applying the replacements.</returns> /// <remarks><see cref="LNodeExt.MatchesPattern"/> is used for matching.</remarks> public static RVList<LNode> Replace(RVList<LNode> stmts, Pair<LNode, LNode>[] patterns, out int replacementCount) { // This list is used to support simple token replacement in TokenTrees _tokenTreeRepls = InternalList<Triplet<Symbol, LNode, int>>.Empty; foreach (var pair in patterns) // Look for Id => Id or Id => Literal if (pair.A.IsId && (pair.B.IsId || pair.B.IsLiteral)) _tokenTreeRepls.Add(new Triplet<Symbol,LNode,int>(pair.A.Name, pair.B, 0)); // Scan the syntax tree for things to replace... int count = 0; var temp = new MMap<Symbol, LNode>(); var output = stmts.SmartSelect(stmt => stmt.ReplaceRecursive(n => { LNode r = TryReplaceHere(n, patterns, temp); if (r != null) count++; return r; })); replacementCount = count; return output; }
/// <summary> /// Decodes a collection of certificate policies from a ASN.1-encoded byte array. /// <para> /// Byte array in the <strong>rawData</strong> parameter must represent certificate policies extension value. /// </para> /// </summary> /// <param name="rawData">ASN.1-encoded byte array that represents certificate policies extension value.</param> /// <exception cref="Asn1InvalidTagException">The data in the <strong>rawData</strong> parameter is not valid /// extension value.</exception> /// <exception cref="ArgumentNullException"><strong>rawData</strong> is null.</exception> public void Decode(Byte[] rawData) { if (rawData == null) { throw new ArgumentNullException(nameof(rawData)); } InternalList.Clear(); Asn1Reader asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new Asn1InvalidTagException(asn.Offset); } asn.MoveNext(); do { InternalList.Add(new X509CertificatePolicy(asn.GetTagRawData())); } while (asn.MoveNextCurrentLevel()); }
/// <summary> /// Decodes ASN.1-encoded certificate trust list collection. /// </summary> /// <param name="rawData">ASN.1-encoded byte array that represents certificate trust list collection.</param> /// <exception cref="ArgumentNullException"> /// <strong>rawData</strong> parameter is null. /// </exception> public void Decode(Byte[] rawData) { if (rawData == null) { throw new ArgumentNullException(nameof(rawData)); } Clear(); var asn = new Asn1Reader(rawData); if (asn.PayloadLength == 0) { return; } asn.MoveNext(); do { var entry = new X509CertificateTrustListEntry(new AsnEncodedData(asn.GetTagRawData())); InternalList.Add(entry); } while (asn.MoveNextCurrentLevel()); }
/// <summary> /// Decodes ASN.1 encoded byte array to an array of <see cref="X509AlternativeName"/> objects. /// </summary> /// <param name="rawData">ASN.1-encoded byte array.</param> /// <exception cref="ArgumentNullException"> /// <strong>rawData</strong> parameter is null. /// </exception> /// <exception cref="Asn1InvalidTagException"> /// The data in the <strong>rawData</strong> parameter is not valid array of <see cref="X509AlternativeName"/> objects. /// </exception> public void Decode(Byte[] rawData) { if (IsReadOnly) { throw new AccessViolationException(Error.E_COLLECTIONCLOSED); } if (rawData == null) { throw new ArgumentNullException(nameof(rawData)); } InternalList.Clear(); var asn = new Asn1Reader(rawData); if (!asn.MoveNext()) { return; } do { InternalList.Add(new X509AlternativeName(asn.GetTagRawData())); } while (asn.MoveNextCurrentLevel()); }
private void AutoAddBranchForAndPred(ref InternalList<PredictionBranch> children, AndPred andPred, List<KthSet> alts, Set<AndPred> matched, MSet<AndPred> falsified) { if (!falsified.Contains(andPred)) { var innerMatched = matched.With(andPred); var result = new PredictionBranch(new Set<AndPred>().With(andPred), ComputeAssertionTree2(alts, innerMatched)); falsified.Add(andPred); RemoveFalsifiedCases(alts, falsified); children.Add(result); } }