Ejemplo n.º 1
0
        /** Return the set of all methods either inherited or not */
        public IEnumerable <MethodSymbol> GetMethods()
        {
            LinkedHashSet <MethodSymbol> methods = new LinkedHashSet <MethodSymbol>();
            ClassSymbol superClassScope          = GetBaseClassScope();
            IEnumerable <MethodSymbol> temp;

            if (superClassScope != null)
            {
                temp = superClassScope.GetMethods();
                foreach (var item in temp)
                {
                    methods.Add(item);
                }
            }
            temp = GetDefinedMethods();
            if (temp != null)
            {
                foreach (var item in temp)
                {
                    methods.Remove(item); // override method from superclass
                }
                temp = GetDefinedMethods();
                foreach (var item in temp)
                {
                    methods.Remove(item); // override method from superclass
                }
            }
            return(methods);
        }
Ejemplo n.º 2
0
        public void TestFirstAndLast()
        {
            var set = new LinkedHashSet <string>(EqualityComparer <string> .Default);

            set.Add("10");

            Assert.That(set.First, Is.EqualTo("10"));
            Assert.That(set.Last, Is.EqualTo("10"));

            set.Add("20");
            set.Add("30");

            Assert.That(set.First, Is.EqualTo("10"));
            Assert.That(set.Last, Is.EqualTo("30"));

            set.Remove("10");
            set.Remove("30");

            Assert.That(set.First, Is.EqualTo("20"));
            Assert.That(set.Last, Is.EqualTo("20"));

            set.Add("10");

            Assert.That(set.First, Is.EqualTo("20"));
            Assert.That(set.Last, Is.EqualTo("10"));

            set.Add("30");

            Assert.That(set.First, Is.EqualTo("20"));
            Assert.That(set.Last, Is.EqualTo("30"));
        }
Ejemplo n.º 3
0
        public override void Update(
            EventBean[] newData,
            EventBean[] oldData)
        {
            _agentInstanceContext.AuditProvider.View(newData, oldData, _agentInstanceContext, _lengthWindowViewFactory);
            _agentInstanceContext.InstrumentationProvider.QViewProcessIRStream(
                _lengthWindowViewFactory,
                newData,
                oldData);

            EventBean[] expiredArr = null;
            if (oldData != null) {
                foreach (var anOldData in oldData) {
                    _indexedEvents.Remove(anOldData);
                    InternalHandleRemoved(anOldData);
                }

                expiredArr = oldData;
            }

            // add data points to the window
            // we don't care about removed data from a prior view
            if (newData != null) {
                foreach (var newEvent in newData) {
                    _indexedEvents.Add(newEvent);
                    InternalHandleAdded(newEvent);
                }
            }

            // Check for any events that get pushed out of the window
            var expiredCount = _indexedEvents.Count - Size;
            if (expiredCount > 0) {
                expiredArr = new EventBean[expiredCount];
                using (var enumerator = _indexedEvents.GetEnumerator()) {
                    for (var ii = 0; enumerator.MoveNext() && ii < expiredCount; ii++) {
                        expiredArr[ii] = enumerator.Current;
                    }
                }

                foreach (var anExpired in expiredArr) {
                    _indexedEvents.Remove(anExpired);
                    InternalHandleExpired(anExpired);
                }
            }

            // If there are child views, call update method
            if (child != null) {
                _agentInstanceContext.InstrumentationProvider.QViewIndicate(
                    _lengthWindowViewFactory,
                    newData,
                    expiredArr);
                child.Update(newData, expiredArr);
                _agentInstanceContext.InstrumentationProvider.AViewIndicate();
            }

            _agentInstanceContext.InstrumentationProvider.AViewProcessIRStream();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Checks recursively that the node has a circular dependency.
 /// </summary>
 /// <param name="node">
 /// The node of the DAG.
 /// </param>
 /// <exception cref="CircularDependencyException">
 /// if the circular dependency has occurred.
 /// </exception>
 public void Check(T node)
 {
     if (!set.Add(node))
     {
         var list = new List <T>(set)
         {
             node,
         };
         var index = list.IndexOf(node);
         var loop  = list.GetRange(index, list.Count - index);
         throw CircularDependencyException.Of(loop);
     }
     try
     {
         var dependencies = getDependencies(node)
                            .Where(d => !checkedSet.Contains(d));
         foreach (var d in dependencies)
         {
             Check(d);
         }
         checkedSet.Add(node);
     }
     finally
     {
         set.Remove(node);
     }
 }
Ejemplo n.º 5
0
        private bool RectanglesEqualWithEps(IList <Rectangle> cacheRects, IList <Rectangle> keyRects)
        {
            if (keyRects == null || cacheRects.Count != keyRects.Count)
            {
                return(false);
            }
            ICollection <Rectangle> cacheRectsSet = new LinkedHashSet <Rectangle>(cacheRects);

            foreach (Rectangle keyArea in keyRects)
            {
                bool found = false;
                foreach (Rectangle cacheArea in cacheRectsSet)
                {
                    if (keyArea.EqualsWithEpsilon(cacheArea))
                    {
                        found = true;
                        cacheRectsSet.Remove(cacheArea);
                        break;
                    }
                }
                if (!found)
                {
                    break;
                }
            }
            return(cacheRectsSet.IsEmpty());
        }
Ejemplo n.º 6
0
        public void TestEqualityComparer()
        {
            var set = new LinkedHashSet <int>(AlwaysEqualEqualityComparer <int> .Instance);

            Assert.That(set.Add(10), Is.True);
            Assert.That(set.Add(20), Is.False);
            Assert.That(set.Add(30), Is.False);

            Assert.That(set.Count, Is.EqualTo(1));

            Assert.That(set.Remove(40), Is.True);
            Assert.That(set.Remove(50), Is.False);
            Assert.That(set.Remove(10), Is.False);

            Assert.That(set.Count, Is.EqualTo(0));
        }
Ejemplo n.º 7
0
        public static int[] Random(int min, int max, int count)
        {
            int[] result            = new int[Math.Min(count, max - min + 1)];
            int   index             = 0;
            LinkedHashSet <int> set = new LinkedHashSet <int>();

            for (int i = min; i <= max; i++)
            {
                set.AddItem(i);
            }
            while (index < result.Length)
            {
                int r = Random(0, set.Count - 1);
                if (r < set.Count)
                {
                    result[index] = GetInt(set, r);
                    set.Remove(result[index]);
                }
                else
                {
                    break;
                }
                index++;
            }
            return(result);
        }
Ejemplo n.º 8
0
        public void Remove(EventBean theEvent)
        {
            var key = GetIndexedValue(theEvent);

            if (key == null)
            {
                NullKeyedValues.Remove(theEvent);
                return;
            }

            key = Coerce(key);

            var events = PropertyIndex.Get(key);

            if (events == null)
            {
                return;
            }

            if (!events.Remove(theEvent))
            {
                // Not an error, its possible that an old-data event is artificial (such as for statistics) and
                // thus did not correspond to a new-data event raised earlier.
                return;
            }

            if (events.IsEmpty())
            {
                PropertyIndex.Remove(key);
            }
        }
Ejemplo n.º 9
0
        private void ProcessNow()
        {
            Log.D(Database.Tag, this + ": processNow() called");
            scheduled = false;
            IList <T> toProcess = new AList <T>();

            lock (this)
            {
                if (inbox == null || inbox.Count == 0)
                {
                    Log.D(Database.Tag, this + ": processNow() called, but inbox is empty");
                    return;
                }
                else
                {
                    if (inbox.Count <= capacity)
                    {
                        Log.D(Database.Tag, this + ": processNow() called, inbox size: " + inbox.Count);
                        Log.D(Database.Tag, this + ": inbox.size() <= capacity, adding " + inbox.Count +
                              " items to toProcess array");
                        Sharpen.Collections.AddAll(toProcess, inbox);
                        inbox = null;
                    }
                    else
                    {
                        Log.D(Database.Tag, this + ": processNow() called, inbox size: " + inbox.Count);
                        int i = 0;
                        foreach (T item in inbox)
                        {
                            toProcess.AddItem(item);
                            i += 1;
                            if (i >= capacity)
                            {
                                break;
                            }
                        }
                        foreach (T item_1 in toProcess)
                        {
                            Log.D(Database.Tag, this + ": processNow() removing " + item_1 + " from inbox");
                            inbox.Remove(item_1);
                        }
                        Log.D(Database.Tag, this + ": inbox.size() > capacity, moving " + toProcess.Count
                              + " items from inbox -> toProcess array");
                        // There are more objects left, so schedule them Real Soon:
                        ScheduleWithDelay(0);
                    }
                }
            }
            if (toProcess != null && toProcess.Count > 0)
            {
                Log.D(Database.Tag, this + ": invoking processor with " + toProcess.Count + " items "
                      );
                processor.Process(toProcess);
            }
            else
            {
                Log.D(Database.Tag, this + ": nothing to process");
            }
            lastProcessedTime = Runtime.CurrentTimeMillis();
        }
Ejemplo n.º 10
0
        public override void Update(
            EventBean[] newData,
            EventBean[] oldData)
        {
            _agentInstanceContext.AuditProvider.View(newData, oldData, _agentInstanceContext, _keepAllViewFactory);
            _agentInstanceContext.InstrumentationProvider.QViewProcessIRStream(_keepAllViewFactory, newData, oldData);

            if (newData != null) {
                foreach (var newEvent in newData) {
                    _indexedEvents.Add(newEvent);
                    InternalHandleAdded(newEvent);
                }
            }

            if (oldData != null) {
                foreach (var anOldData in oldData) {
                    _indexedEvents.Remove(anOldData);
                    InternalHandleRemoved(anOldData);
                }
            }

            // update event buffer for access by expressions, if any
            _viewUpdatedCollection?.Update(newData, oldData);

            _agentInstanceContext.InstrumentationProvider.QViewIndicate(_keepAllViewFactory, newData, oldData);
            child.Update(newData, oldData);
            _agentInstanceContext.InstrumentationProvider.AViewIndicate();

            _agentInstanceContext.InstrumentationProvider.AViewProcessIRStream();
        }
Ejemplo n.º 11
0
        /// <summary>Splits a comma separated value <code>String</code>, trimming leading and trailing whitespace on each value.
        ///     </summary>
        /// <remarks>
        /// Splits a comma separated value <code>String</code>, trimming leading and trailing whitespace on each value.
        /// Duplicate and empty values are removed.
        /// </remarks>
        /// <param name="str">a comma separated <String> with values</param>
        /// <returns>a <code>Collection</code> of <code>String</code> values</returns>
        public static ICollection <string> GetTrimmedStringCollection(string str)
        {
            ICollection <string> set = new LinkedHashSet <string>(Arrays.AsList(GetTrimmedStrings
                                                                                    (str)));

            set.Remove(string.Empty);
            return(set);
        }
Ejemplo n.º 12
0
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QViewProcessIRStream(this, _timeBatchViewFactory.ViewName, newData, oldData);
            }

            if (oldData != null)
            {
                for (int i = 0; i < oldData.Length; i++)
                {
                    _currentBatch.Remove(oldData[i]);
                    InternalHandleRemoved(oldData[i]);
                }
            }

            // we don't care about removed data from a prior view
            if ((newData == null) || (newData.Length == 0))
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AViewProcessIRStream();
                }
                return;
            }

            // If we have an empty window about to be filled for the first time, schedule a callback
            if (_currentBatch.IsEmpty())
            {
                if (_currentReferencePoint == null)
                {
                    _currentReferencePoint = _initialReferencePoint;
                    if (_currentReferencePoint == null)
                    {
                        _currentReferencePoint = _agentInstanceContext.StatementContext.SchedulingService.Time;
                    }
                }

                // Schedule the next callback if there is none currently scheduled
                if (!_isCallbackScheduled)
                {
                    ScheduleCallback();
                    _isCallbackScheduled = true;
                }
            }

            // add data points to the timeWindow
            foreach (EventBean newEvent in newData)
            {
                _currentBatch.Add(newEvent);
            }

            // We do not update child views, since we batch the events.
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AViewProcessIRStream();
            }
        }
Ejemplo n.º 13
0
        /**
         * Remove the cell at the specified location from this Cell World. This
         * allows you to introduce barriers into different location.
         *
         * @param x
         *            the x dimension of the cell to be removed.
         * @param y
         *            the y dimension of the cell to be removed.
         */
        public void removeCell(int x, int y)
        {
            Dictionary <int, Cell <C> > xCol = cellLookup[x];

            if (null != xCol)
            {
                xCol.Remove(y);
                cells.Remove(xCol[y]);
            }
        }
Ejemplo n.º 14
0
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QViewProcessIRStream(this, _lengthFirstFactory.ViewName, newData, oldData); }

            OneEventCollection newDataToPost = null;
            OneEventCollection oldDataToPost = null;

            // add data points to the window as long as its not full, ignoring later events
            if (newData != null)
            {
                foreach (EventBean aNewData in newData)
                {
                    if (_indexedEvents.Count < Size)
                    {
                        if (newDataToPost == null)
                        {
                            newDataToPost = new OneEventCollection();
                        }
                        newDataToPost.Add(aNewData);
                        _indexedEvents.Add(aNewData);
                        InternalHandleAdded(aNewData);
                    }
                }
            }

            if (oldData != null)
            {
                foreach (EventBean anOldData in oldData)
                {
                    bool removed = _indexedEvents.Remove(anOldData);
                    if (removed)
                    {
                        if (oldDataToPost == null)
                        {
                            oldDataToPost = new OneEventCollection();
                        }
                        oldDataToPost.Add(anOldData);
                        InternalHandleRemoved(anOldData);
                    }
                }
            }

            // If there are child views, call Update method
            if (HasViews && ((newDataToPost != null) || (oldDataToPost != null)))
            {
                EventBean[] nd = (newDataToPost != null) ? newDataToPost.ToArray() : null;
                EventBean[] od = (oldDataToPost != null) ? oldDataToPost.ToArray() : null;
                if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QViewIndicate(this, _lengthFirstFactory.ViewName, nd, od); }
                UpdateChildren(nd, od);
                if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AViewIndicate(); }
            }

            if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AViewProcessIRStream(); }
        }
Ejemplo n.º 15
0
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QViewProcessIRStream(this, _lengthBatchViewFactory.ViewName, newData, oldData);
            }

            if (oldData != null)
            {
                for (int i = 0; i < oldData.Length; i++)
                {
                    if (CurrentBatch.Remove(oldData[i]))
                    {
                        InternalHandleRemoved(oldData[i]);
                    }
                }
            }

            // we don't care about removed data from a prior view
            if ((newData == null) || (newData.Length == 0))
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AViewProcessIRStream();
                }
                return;
            }

            // add data points to the current batch
            foreach (EventBean newEvent in newData)
            {
                CurrentBatch.Add(newEvent);
            }

            // check if we reached the minimum size
            if (CurrentBatch.Count < _size)
            {
                // done if no overflow
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AViewProcessIRStream();
                }
                return;
            }

            SendBatch();

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AViewProcessIRStream();
            }
        }
Ejemplo n.º 16
0
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            using (Instrument.With(
                       i => i.QViewProcessIRStream(this, _timeFirstViewFactory.ViewName, newData, oldData),
                       i => i.AViewProcessIRStream()))
            {
                OneEventCollection oldDataToPost = null;
                if (oldData != null)
                {
                    foreach (EventBean anOldData in oldData)
                    {
                        bool removed = _events.Remove(anOldData);
                        if (removed)
                        {
                            if (oldDataToPost == null)
                            {
                                oldDataToPost = new OneEventCollection();
                            }
                            oldDataToPost.Add(anOldData);
                            InternalHandleRemoved(anOldData);
                        }
                    }
                }

                // add data points to the timeWindow
                OneEventCollection newDataToPost = null;
                if ((!_isClosed) && (newData != null))
                {
                    foreach (EventBean aNewData in newData)
                    {
                        _events.Add(aNewData);
                        if (newDataToPost == null)
                        {
                            newDataToPost = new OneEventCollection();
                        }
                        newDataToPost.Add(aNewData);
                        InternalHandleAdded(aNewData);
                    }
                }

                // If there are child views, call Update method
                if ((HasViews) && ((newDataToPost != null) || (oldDataToPost != null)))
                {
                    EventBean[] nd = (newDataToPost != null) ? newDataToPost.ToArray() : null;
                    EventBean[] od = (oldDataToPost != null) ? oldDataToPost.ToArray() : null;
                    Instrument.With(
                        i => i.QViewIndicate(this, _timeFirstViewFactory.ViewName, nd, od),
                        i => i.AViewIndicate(),
                        () => UpdateChildren(nd, od));
                }
            }
        }
Ejemplo n.º 17
0
        public void LinkedHashSet_Generic_Constructor_LinkedHashSet_SparselyFilled(int count)
        {
            LinkedHashSet <T> source         = (LinkedHashSet <T>)CreateEnumerable(EnumerableType.LinkedHashSet, null, count, 0, 0);
            List <T>          sourceElements = source.ToList();

            foreach (int i in NonSquares(count))
            {
                source.Remove(sourceElements[i]);// Unevenly spaced survivors increases chance of catching any spacing-related bugs.
            }
            LinkedHashSet <T> set = new LinkedHashSet <T>(source, GetIEqualityComparer());

            Assert.True(set.SetEquals(source));
        }
Ejemplo n.º 18
0
        public void LinkedHashSet_Generic_RemoveWhere_NewObject() // Regression Dev10_624201
        {
            object[] array             = new object[2];
            object   obj               = new object();
            LinkedHashSet <object> set = new LinkedHashSet <object>();

            set.Add(obj);
            set.Remove(obj);
            foreach (object o in set)
            {
            }
            set.CopyTo(array, 0, 2);
            set.RemoveWhere((element) => { return(false); });
        }
Ejemplo n.º 19
0
        public void TestAddRemove()
        {
            var set = new LinkedHashSet <int>(EqualityComparer <int> .Default);

            Assert.That(set.Add(11), Is.True);
            Assert.That(set.Add(21), Is.True);
            Assert.That(set.Add(31), Is.True);

            Assert.That(set.Count, Is.EqualTo(3));
            Assert.That(set.ToArray(), Is.EqualTo(new int[] { 11, 21, 31 }));

            Assert.That(set.Add(31), Is.False);
            Assert.That(set.Add(21), Is.False);
            Assert.That(set.Add(11), Is.False);

            Assert.That(set.Count, Is.EqualTo(3));
            Assert.That(set.ToArray(), Is.EqualTo(new int[] { 11, 21, 31 }));

            Assert.That(set.Add(42), Is.True);

            Assert.That(set.Count, Is.EqualTo(4));
            Assert.That(set.ToArray(), Is.EqualTo(new int[] { 11, 21, 31, 42 }));

            Assert.That(set.Remove(21), Is.True);
            Assert.That(set.Remove(31), Is.True);
            Assert.That(set.Remove(52), Is.False);

            Assert.That(set.Count, Is.EqualTo(2));
            Assert.That(set.ToArray(), Is.EqualTo(new int[] { 11, 42 }));

            Assert.That(set.Add(13), Is.True);
            Assert.That(set.Add(23), Is.True);

            Assert.That(set.Count, Is.EqualTo(4));
            Assert.That(set.ToArray(), Is.EqualTo(new int[] { 11, 42, 13, 23 }));
        }
Ejemplo n.º 20
0
        public void EnsureCapacity_Generic_GrowCapacityWithFreeList(int setLength)
        {
            LinkedHashSet <T> set = (LinkedHashSet <T>)GenericISetFactory(setLength);

            // Remove the first element to ensure we have a free list.
            Assert.True(set.Remove(set.ElementAt(0)));

            int currentCapacity = set.EnsureCapacity(0);

            Assert.True(currentCapacity > 0);

            int newCapacity = set.EnsureCapacity(currentCapacity + 1);

            Assert.True(newCapacity > currentCapacity);
        }
Ejemplo n.º 21
0
        public override void Update(
            EventBean[] newData,
            EventBean[] oldData)
        {
            agentInstanceContext.AuditProvider.View(newData, oldData, agentInstanceContext, lengthFirstFactory);
            agentInstanceContext.InstrumentationProvider.QViewProcessIRStream(lengthFirstFactory, newData, oldData);

            OneEventCollection newDataToPost = null;
            OneEventCollection oldDataToPost = null;

            // add data points to the window as long as its not full, ignoring later events
            if (newData != null) {
                foreach (var aNewData in newData) {
                    if (indexedEvents.Count < Size) {
                        if (newDataToPost == null) {
                            newDataToPost = new OneEventCollection();
                        }

                        newDataToPost.Add(aNewData);
                        indexedEvents.Add(aNewData);
                    }
                }
            }

            if (oldData != null) {
                foreach (var anOldData in oldData) {
                    var removed = indexedEvents.Remove(anOldData);
                    if (removed) {
                        if (oldDataToPost == null) {
                            oldDataToPost = new OneEventCollection();
                        }

                        oldDataToPost.Add(anOldData);
                    }
                }
            }

            // If there are child views, call update method
            if (child != null && (newDataToPost != null || oldDataToPost != null)) {
                var nd = newDataToPost != null ? newDataToPost.ToArray() : null;
                var od = oldDataToPost != null ? oldDataToPost.ToArray() : null;
                agentInstanceContext.InstrumentationProvider.QViewIndicate(lengthFirstFactory, nd, od);
                child.Update(nd, od);
                agentInstanceContext.InstrumentationProvider.AViewIndicate();
            }

            agentInstanceContext.InstrumentationProvider.AViewProcessIRStream();
        }
Ejemplo n.º 22
0
        public void LinkedHashSet_Generic_TrimExcess_AfterRemovingOneElement(int setLength)
        {
            if (setLength > 0)
            {
                LinkedHashSet <T> set      = (LinkedHashSet <T>)GenericISetFactory(setLength);
                List <T>          expected = set.ToList();
                T elementToRemove          = set.ElementAt(0);

                set.TrimExcess();
                Assert.True(set.Remove(elementToRemove));
                expected.Remove(elementToRemove);
                set.TrimExcess();

                Assert.True(set.SetEquals(expected));
            }
        }
Ejemplo n.º 23
0
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QViewProcessIRStream(this, _keepAllViewFactory.ViewName, newData, oldData);
            }

            if (newData != null)
            {
                foreach (EventBean newEvent in newData)
                {
                    _indexedEvents.Add(newEvent);
                    InternalHandleAdded(newEvent);
                }
            }

            if (oldData != null)
            {
                foreach (EventBean anOldData in oldData)
                {
                    _indexedEvents.Remove(anOldData);
                    InternalHandleRemoved(anOldData);
                }
            }

            // Update event buffer for access by expressions, if any
            if (_viewUpdatedCollection != null)
            {
                _viewUpdatedCollection.Update(newData, oldData);
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QViewIndicate(this, _keepAllViewFactory.ViewName, newData, oldData);
            }
            UpdateChildren(newData, oldData);
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AViewIndicate();
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AViewProcessIRStream();
            }
        }
Ejemplo n.º 24
0
        public override void Visit(TypeAttributes access, String name, Type superName, Type[] interfaces)
        {
            LinkedHashSet <Type> ints = new LinkedHashSet <Type>(interfaces);

            ints.AddAll(newInterfaces);
            Type type = State.CurrentType;

            while (type != null && type != typeof(Object))
            {
                foreach (Type alreadyImplementedInterface in type.GetInterfaces())
                {
                    ints.Remove(alreadyImplementedInterface);
                }
                type = type.BaseType;
            }
            base.Visit(access, name, superName, ints.ToArray());
        }
Ejemplo n.º 25
0
        public void Remove_NonDefaultComparer_ComparerUsed(int capacity)
        {
            var c   = new TrackingEqualityComparer <T>();
            var set = new LinkedHashSet <T>(capacity, c);

            AddToCollection(set, capacity);
            T first = set.First();

            c.EqualsCalls      = 0;
            c.GetHashCodeCalls = 0;

            Assert.Equal(capacity, set.Count);
            set.Remove(first);
            Assert.Equal(capacity - 1, set.Count);

            Assert.InRange(c.EqualsCalls, 1, int.MaxValue);
            Assert.InRange(c.GetHashCodeCalls, 1, int.MaxValue);
        }
Ejemplo n.º 26
0
        public override void Update(
            EventBean[] newData,
            EventBean[] oldData)
        {
            agentInstanceContext.AuditProvider.View(newData, oldData, agentInstanceContext, factory);
            agentInstanceContext.InstrumentationProvider.QViewProcessIRStream(factory, newData, oldData);

            if (oldData != null) {
                for (var i = 0; i < oldData.Length; i++) {
                    currentBatch.Remove(oldData[i]);
                }
            }

            // we don't care about removed data from a prior view
            if (newData == null || newData.Length == 0) {
                agentInstanceContext.InstrumentationProvider.AViewProcessIRStream();
                return;
            }

            // If we have an empty window about to be filled for the first time, schedule a callback
            if (currentBatch.IsEmpty()) {
                if (currentReferencePoint == null) {
                    currentReferencePoint = factory.optionalReferencePoint;
                    if (currentReferencePoint == null) {
                        currentReferencePoint = agentInstanceContext.StatementContext.SchedulingService.Time;
                    }
                }

                // Schedule the next callback if there is none currently scheduled
                if (!isCallbackScheduled) {
                    ScheduleCallback();
                    isCallbackScheduled = true;
                }
            }

            // add data points to the timeWindow
            foreach (var newEvent in newData) {
                currentBatch.Add(newEvent);
            }

            // We do not update child views, since we batch the events.
            agentInstanceContext.InstrumentationProvider.AViewProcessIRStream();
        }
Ejemplo n.º 27
0
        public ImmutableArray <string> GetUnfinishedLeafTasks()
        {
            IList <Allocation> allUnfinished    = GetUnfinishedAllocations();
            ISet <Allocation>  unfinishedLeaves = new LinkedHashSet <Allocation>(allUnfinished); // preserves order

            foreach (Allocation allocation in allUnfinished)

            {
                Maybe <Allocation> parent = allocation.GetParent();

                while (parent.IsPresent())
                {
                    unfinishedLeaves.Remove(parent.Get());
                    parent = parent.Get().GetParent();
                }
            }

            return(ImmutableArray.CreateRange(
                       unfinishedLeaves.Select(a => a.GetDescription()).ToList()));
        }
Ejemplo n.º 28
0
 private void ActualizeNamespacesInStructTreeRoot()
 {
     if (namespaces.Count > 0)
     {
         PdfStructTreeRoot           structTreeRoot = GetDocument().GetStructTreeRoot();
         PdfArray                    rootNamespaces = structTreeRoot.GetNamespacesObject();
         ICollection <PdfDictionary> newNamespaces  = new LinkedHashSet <PdfDictionary>(namespaces);
         for (int i = 0; i < rootNamespaces.Size(); ++i)
         {
             newNamespaces.Remove(rootNamespaces.GetAsDictionary(i));
         }
         foreach (PdfDictionary newNs in newNamespaces)
         {
             rootNamespaces.Add(newNs);
         }
         if (!newNamespaces.IsEmpty())
         {
             structTreeRoot.SetModified();
         }
     }
 }
Ejemplo n.º 29
0
        public override void Update(
            EventBean[] newData,
            EventBean[] oldData)
        {
            agentInstanceContext.AuditProvider.View(newData, oldData, agentInstanceContext, lengthBatchViewFactory);
            agentInstanceContext.InstrumentationProvider.QViewProcessIRStream(lengthBatchViewFactory, newData, oldData);

            if (oldData != null) {
                for (var i = 0; i < oldData.Length; i++) {
                    if (currentBatch.Remove(oldData[i])) {
                        InternalHandleRemoved(oldData[i]);
                    }
                }
            }

            // we don't care about removed data from a prior view
            if (newData == null || newData.Length == 0) {
                agentInstanceContext.InstrumentationProvider.AViewProcessIRStream();
                return;
            }

            // add data points to the current batch
            foreach (var newEvent in newData) {
                currentBatch.Add(newEvent);
            }

            // check if we reached the minimum size
            if (currentBatch.Count < Size) {
                // done if no overflow
                agentInstanceContext.InstrumentationProvider.AViewProcessIRStream();
                return;
            }

            SendBatch();

            agentInstanceContext.InstrumentationProvider.AViewProcessIRStream();
        }
Ejemplo n.º 30
0
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QViewProcessIRStream(this, _lengthWindowViewFactory.ViewName, newData, oldData);
            }

            EventBean[] expiredArr = null;
            if (oldData != null)
            {
                foreach (EventBean anOldData in oldData)
                {
                    _indexedEvents.Remove(anOldData);
                    InternalHandleRemoved(anOldData);
                }

                expiredArr = oldData;
            }

            // add data points to the window
            // we don't care about removed data from a prior view
            if (newData != null)
            {
                foreach (EventBean newEvent in newData)
                {
                    _indexedEvents.Add(newEvent);
                    InternalHandleAdded(newEvent);
                }
            }

            // Check for any events that get pushed out of the window
            int expiredCount = _indexedEvents.Count - _size;

            if (expiredCount > 0)
            {
                expiredArr = _indexedEvents.Take(expiredCount).ToArray();
                foreach (EventBean anExpired in expiredArr)
                {
                    _indexedEvents.Remove(anExpired);
                    InternalHandleExpired(anExpired);
                }
            }

            // If there are child views, call Update method
            if (HasViews)
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QViewIndicate(this, _lengthWindowViewFactory.ViewName, newData, expiredArr);
                }
                UpdateChildren(newData, expiredArr);
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AViewIndicate();
                }
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AViewProcessIRStream();
            }
        }
Ejemplo n.º 31
0
     public void test_RemoveLjava_lang_Object()
     {
         int size = hs.Size();
         hs.Remove((Object) 98);
         Assert.IsTrue(!hs.Contains(98), "Failed to Remove element");
         Assert.IsTrue(hs.Size() == size - 1, "Failed to decrement set size");
 
         LinkedHashSet<Object> s = new LinkedHashSet<Object>();
         s.Add(null);
         Assert.IsTrue(s.Remove(null), "Cannot handle null");
     }