예제 #1
0
        public virtual void ShouldBeAbleToAddMultipleElementsToList()
        {
            LIST <ST, string> testList = new LISTImpl <ST, string>(typeof(STImpl));
            IList <string>    rawList  = testList.RawList <string>();

            rawList.Add("newString1");
            rawList.Add("newString2");
            Assert.IsFalse(testList.Value.IsEmpty());
            Assert.AreEqual(2, testList.Value.Count);
            Assert.AreEqual("newString1", getElement(testList, 0).Value);
            Assert.AreEqual("newString2", getElement(testList, 1).Value);
            Assert.IsNull(getElement(testList, 0).NullFlavor);
            Assert.IsNull(getElement(testList, 1).NullFlavor);
            rawList.Insert(0, "newString3");
            Assert.AreEqual(3, testList.Value.Count);
            Assert.AreEqual("newString3", getElement(testList, 0).Value);
            bool result = rawList.AddAll(Arrays.AsList("newString4", "newString5"));

            Assert.IsTrue(result);
            Assert.AreEqual(5, testList.Value.Count);
            Assert.AreEqual("newString4", getElement(testList, 3).Value);
            Assert.AreEqual("newString5", getElement(testList, 4).Value);
            Assert.AreEqual(5, testList.Value.Count);
            result = rawList.AddAll(2, Arrays.AsList("newString6", "newString7"));
            Assert.IsTrue(result);
            Assert.AreEqual(7, testList.Value.Count);
            Assert.AreEqual("newString3", getElement(testList, 0).Value);
            Assert.AreEqual("newString1", getElement(testList, 1).Value);
            Assert.AreEqual("newString6", getElement(testList, 2).Value);
            Assert.AreEqual("newString7", getElement(testList, 3).Value);
            Assert.AreEqual("newString2", getElement(testList, 4).Value);
            Assert.AreEqual("newString4", getElement(testList, 5).Value);
            Assert.AreEqual("newString5", getElement(testList, 6).Value);
        }
예제 #2
0
        public static void ListEqualityComparers()
        {
            col1.AddAll(new[] { 7, 9, 13 });
            col2.AddAll(new[] { 7, 9, 13 });
            col3.AddAll(new[] { 9, 7, 13 });

            // Default equality and hasher == sequenced equality and hasher
            HashSet <IList <int> > hs1 = new HashSet <IList <int> >();

            Equalities("Default equality (sequenced equality)", hs1.EqualityComparer);
            hs1.Add(col1); hs1.Add(col2); hs1.Add(col3);
            Console.WriteLine("hs1.Count = {0}", hs1.Count);

            // Sequenced equality and hasher
            SCG.IEqualityComparer <IList <int> > seqEqualityComparer
                = SequencedCollectionEqualityComparer <IList <int>, int> .Default;
            HashSet <IList <int> > hs2 = new HashSet <IList <int> >(seqEqualityComparer);

            Equalities("Sequenced equality", hs2.EqualityComparer);
            hs2.Add(col1); hs2.Add(col2); hs2.Add(col3);
            Console.WriteLine("hs2.Count = {0}", hs2.Count);

            // Unsequenced equality and hasher
            SCG.IEqualityComparer <IList <int> > unseqEqualityComparer
                = UnsequencedCollectionEqualityComparer <IList <int>, int> .Default;
            HashSet <IList <int> > hs3 = new HashSet <IList <int> >(unseqEqualityComparer);

            Equalities("Unsequenced equality", hs3.EqualityComparer);
            hs3.Add(col1); hs3.Add(col2); hs3.Add(col3);
            Console.WriteLine("hs3.Count = {0}", hs3.Count);
        }
예제 #3
0
 public virtual void EventOccurred(IEventData data, EventType type)
 {
     if (data is TextRenderInfo)
     {
         parseResult.AddAll(ToCRI((TextRenderInfo)data));
     }
 }
예제 #4
0
        private void TryListViewAsSCIList1(IList <B> mylist)
        {
            B b1_ = new B(), b2_ = new B();
            C c1_ = new C(), c2_ = new C();

            mylist.AddAll(new B[] { new B(), b1_, b2_, c1_, new B() });
            System.Collections.IList list = mylist.View(1, 3);
            Object b1 = b1_, b2 = b2_, c1 = c1_, c2 = c2_;

            // Should be called with a three-element view on ArrayList<B>
            Assert.AreEqual(3, list.Count);
            Assert.IsFalse(list.IsSynchronized);
            Assert.AreNotEqual(null, list.SyncRoot);
            Assert.AreEqual(list.SyncRoot, mylist.SyncRoot);
            Assert.IsTrue(list.Contains(b1));
            Assert.IsTrue(list.Contains(b2));
            Assert.IsTrue(list.Contains(c1));
            Assert.IsFalse(list.Contains(c2));
            Array arrA = new A[3], arrB = new B[3];

            list.CopyTo(arrA, 0);
            list.CopyTo(arrB, 0);
            Assert.AreEqual(b1, arrA.GetValue(0));
            Assert.AreEqual(b1, arrB.GetValue(0));
            Assert.AreEqual(b2, arrA.GetValue(1));
            Assert.AreEqual(b2, arrB.GetValue(1));
            Assert.AreEqual(0, list.IndexOf(b1));
            Assert.AreEqual(-1, list.IndexOf(c2));
        }
예제 #5
0
        /// <summary>
        /// each new command set will be automatically separated by a separator
        /// </summary>
        public void AddMenuCommandSet(MainMenuItem mainMenuItem, IEnumerable <MenuCommand> menuCommands)
        {
            IList <MenuCommand> selectedMenuCommands = null; // make that more clear

            switch (mainMenuItem)
            {
            case MainMenuItem.NavigateMenu:
                if (_navigateMenuCommands == null)
                {
                    _navigateMenuCommands = new List <MenuCommand>();
                }
                else
                {
                    _navigateMenuCommands.Add(MenuCommand.CreateSeparator());
                }

                selectedMenuCommands = _navigateMenuCommands;
                break;

            case MainMenuItem.ViewMenu:
                if (_viewMenuCommands == null)
                {
                    _viewMenuCommands = new List <MenuCommand>();
                }
                else
                {
                    _viewMenuCommands.Add(MenuCommand.CreateSeparator());
                }

                selectedMenuCommands = _viewMenuCommands;
                break;
            }

            selectedMenuCommands.AddAll(menuCommands);
        }
예제 #6
0
        /// <summary>
        ///     Returns all values assigned for a given hint, if any
        /// </summary>
        /// <param name="hintEnum">The hint enum.</param>
        /// <param name="annotations">the to be interogated</param>
        /// <returns>
        ///     hint assigned values or null if none found
        /// </returns>
        public static IList <string> GetHintAssignedValues(
            this HintEnum hintEnum,
            IEnumerable <Attribute> annotations)
        {
            IList <string> allHints = null;

            try {
                foreach (var annotation in annotations)
                {
                    var hintValues = ValidateGetListed(annotation);
                    if (hintValues == null || !hintValues.ContainsKey(hintEnum))
                    {
                        continue;
                    }

                    if (allHints == null)
                    {
                        allHints = hintValues.Get(hintEnum);
                    }
                    else
                    {
                        allHints.AddAll(hintValues.Get(hintEnum));
                    }
                }
            }
            catch (AnnotationException ex) {
                throw new EPException("Failed to interpret hint annotation: " + ex.Message, ex);
            }

            return(allHints);
        }
예제 #7
0
        public ICollection <EventBean> GetCollectKeys(
            EventBean[] eventsPerStream,
            DataMap parent,
            ExprEvaluatorContext context,
            IList <object> keys,
            CompositeIndexQueryResultPostProcessor postProcessor)
        {
            EventBean[] eventsToUse;
            if (_isNWOnTrigger)
            {
                eventsToUse = eventsPerStream;
            }
            else
            {
                Array.Copy(eventsPerStream, 0, _events, 1, eventsPerStream.Length);
                eventsToUse = _events;
            }

            var mk = EventBeanUtility.GetMultiKey(eventsToUse, _evaluators, context, _keyCoercionTypes);

            keys.AddAll(mk.Keys);
            var innerIndex = (DataMap)parent.Get(mk);

            if (innerIndex == null)
            {
                return(null);
            }
            return(_next.GetCollectKeys(eventsPerStream, innerIndex, context, keys, postProcessor));
        }
예제 #8
0
        /// <summary>Populates into the supplied list all aggregation functions within this expression, if any.
        /// <para/>
        /// Populates by going bottom-up such that nested aggregates appear first.
        /// <para/>
        /// i.e. sum(volume * sum(price)) would put first A then B into the list with A=sum(price) and B=sum(volume * A)
        /// </summary>
        /// <param name="topNode">is the expression node to deep inspect</param>
        /// <param name="aggregateNodes">is a list of node to populate into</param>
        public static void GetAggregatesBottomUp(ExprNode topNode, IList <ExprAggregateNode> aggregateNodes)
        {
            // Map to hold per level of the node (1 to Count depth) of expression node a list of aggregation expr nodes, if any
            // exist at that level
            var aggregateExprPerLevel = new OrderedDictionary <int, IList <ExprAggregateNode> >();

            RecursiveAggregateHandleSpecial(topNode, aggregateExprPerLevel, 1);

            // Recursively enter all aggregate functions and their level into map
            RecursiveAggregateEnter(topNode, aggregateExprPerLevel, 1);

            // Done if none found
            if (aggregateExprPerLevel.IsEmpty())
            {
                return;
            }

            // From the deepest (highest) level to the lowest, add aggregates to list
            var deepLevel = aggregateExprPerLevel.Keys.Last();

            for (var i = deepLevel; i >= 1; i--)
            {
                var list = aggregateExprPerLevel.Get(i);
                if (list == null)
                {
                    continue;
                }
                aggregateNodes.AddAll(list);
            }
        }
예제 #9
0
 internal static int[] ReorderLine(IList <LineRenderer.RendererGlyph> line, byte[] lineLevels, byte[] levels
                                   )
 {
     if (!TYPOGRAPHY_MODULE_INITIALIZED)
     {
         logger.Warn("Cannot find advanced typography module, which was implicitly required by one of the layout properties"
                     );
     }
     else
     {
         if (levels == null)
         {
             return(null);
         }
         int[] reorder = (int[])CallMethod(TYPOGRAPHY_PACKAGE + BIDI_ALGORITHM, COMPUTE_REORDERING, new Type[] { typeof(
                                                                                                                     byte[]) }, lineLevels);
         //            int[] reorder = BidiAlgorithm.computeReordering(lineLevels);
         int[] inverseReorder = (int[])CallMethod(TYPOGRAPHY_PACKAGE + BIDI_ALGORITHM, INVERSE_REORDERING, new Type
                                                  [] { typeof(int[]) }, reorder);
         //            int[] inverseReorder = BidiAlgorithm.inverseReordering(reorder);
         IList <LineRenderer.RendererGlyph> reorderedLine = new List <LineRenderer.RendererGlyph>(lineLevels.Length);
         for (int i = 0; i < line.Count; i++)
         {
             reorderedLine.Add(line[reorder[i]]);
             // Mirror RTL glyphs
             if (levels[reorder[i]] % 2 == 1)
             {
                 if (reorderedLine[i].glyph.HasValidUnicode())
                 {
                     int unicode       = reorderedLine[i].glyph.GetUnicode();
                     int pairedBracket = (int)CallMethod(TYPOGRAPHY_PACKAGE + BIDI_BRACKET_MAP, GET_PAIRED_BRACKET, new Type[]
                                                         { typeof(int) }, unicode);
                     //                        int pairedBracket = BidiBracketMap.getPairedBracket(reorderedLine.get(i).glyph.getUnicode());
                     if (pairedBracket != unicode)
                     {
                         PdfFont font = reorderedLine[i].renderer.GetPropertyAsFont(Property.FONT);
                         reorderedLine[i] = new LineRenderer.RendererGlyph(font.GetGlyph(pairedBracket), reorderedLine[i].renderer);
                     }
                 }
             }
         }
         // fix anchorDelta
         for (int i_1 = 0; i_1 < reorderedLine.Count; i_1++)
         {
             Glyph glyph = reorderedLine[i_1].glyph;
             if (glyph.HasPlacement())
             {
                 int oldAnchor      = reorder[i_1] + glyph.GetAnchorDelta();
                 int newPos         = inverseReorder[oldAnchor];
                 int newAnchorDelta = newPos - i_1;
                 glyph.SetAnchorDelta((short)newAnchorDelta);
             }
         }
         line.Clear();
         line.AddAll(reorderedLine);
         return(reorder);
     }
     return(null);
 }
예제 #10
0
 private static void CollectExpressions(IList <ExprNode> expressions, ContextDetailCondition endpoint)
 {
     if (endpoint is ContextDetailConditionCrontab)
     {
         var crontab = (ContextDetailConditionCrontab)endpoint;
         expressions.AddAll(crontab.Crontab);
     }
 }
예제 #11
0
 public void SetServiceProviders(ServiceProvider[] serviceProviders)
 {
     _serviceProviders.Clear();
     if (serviceProviders != null)
     {
         _serviceProviders.AddAll(serviceProviders);
     }
 }
예제 #12
0
 public void SetPrefixDefinitions(PrefixDefinition[] prefixDefinitions)
 {
     _prefixDefinitions.Clear();
     if (prefixDefinitions != null)
     {
         _prefixDefinitions.AddAll(prefixDefinitions);
     }
 }
예제 #13
0
 public void SetServices(Service[] services)
 {
     _services.Clear();
     if (services != null)
     {
         _services.AddAll(services);
     }
 }
예제 #14
0
        /// <summary>Flushes the waiting leaf elements.</summary>
        private void FlushInlineHelper()
        {
            ICollection <IElement> waitingLeaves = inlineHelper.GetWaitingLeaves();

            SetCapitalizeProperty(waitingLeaves);
            spanWrapper.AddAll(waitingLeaves);
            ownLeafElements.AddAll(waitingLeaves);
            inlineHelper.ClearWaitingLeaves();
        }
예제 #15
0
        public virtual void AddChildNodes(ICollection <ExprNode> childNodeColl)
        {
            if (_childNodes.IsReadOnly)
            {
                _childNodes = new List <ExprNode>(_childNodes);
            }

            _childNodes.AddAll(childNodeColl);
        }
예제 #16
0
 private static void CollectExpressions(
     IList<ExprNode> expressions,
     ContextSpecCondition endpoint)
 {
     if (endpoint is ContextSpecConditionCrontab crontab) {
         foreach (var crontabItem in crontab.Crontabs) {
             expressions.AddAll(crontabItem);
         }
     }
 }
예제 #17
0
        public static void SyncWith <T>(this IList <T> list, params T[] syncList)
        {
            //Find new
            var newElements = syncList.ToList().FindAll(value => !list.Contains(value)).ToArray();
            //Find removed
            var removedElements = list.ToList().FindAll(value => !syncList.Contains(value)).ToArray();

            list.RemoveAll(removedElements);
            list.AddAll(newElements);
        }
예제 #18
0
 private static void GetMultikeyForgesRecursive(
     IList<ViewFactoryForge> forges,
     IList<StmtClassForgeableFactory> multikeyForges,
     ViewForgeEnv viewForgeEnv)
 {
     foreach (ViewFactoryForge forge in forges) {
         multikeyForges.AddAll(forge.InitAdditionalForgeables(viewForgeEnv));
         GetMultikeyForgesRecursive(forge.InnerForges, multikeyForges, viewForgeEnv);
     }
 }
예제 #19
0
 /// <summary>
 ///     Ctor.
 /// </summary>
 /// <param name="windowName">is the name of the window to create</param>
 /// <param name="viewArr">is the list of data window views</param>
 public CreateWindowClause(
     string windowName,
     View[] viewArr)
 {
     this.windowName = windowName;
     views = new List<View>();
     if (viewArr != null)
     {
         views.AddAll(viewArr);
     }
 }
예제 #20
0
 private IList <Point> TransformBBox(float left, float bottom, float right, float top, AffineTransform transform
                                     , IList <Point> bBoxPoints)
 {
     bBoxPoints.AddAll(iText.IO.Util.JavaUtil.ArraysAsList(new Point(left, bottom), new Point(right, bottom), new
                                                           Point(right, top), new Point(left, top)));
     foreach (Point point in bBoxPoints)
     {
         transform.Transform(point, point);
     }
     return(bBoxPoints);
 }
예제 #21
0
 public void AddRemove(EventBean[] newData, EventBean[] oldData)
 {
     Instrument.With(
         i => i.QIndexAddRemove(this, newData, oldData),
         i => i.AIndexAddRemove(),
         () =>
     {
         if (newData != null)
         {
             _eventSet.AddAll(newData);
         }
         if (oldData != null)
         {
             foreach (EventBean removeEvent in oldData)
             {
                 _eventSet.Remove(removeEvent);
             }
         }
     });
 }
예제 #22
0
        /// <summary>
        /// Add merge views for any views in the chain requiring a merge (group view).
        /// Appends to the list of view specifications passed in one ore more
        /// new view specifications that represent merge views.
        /// Merge views have the same parameter list as the (group) view they merge data for.
        /// </summary>
        /// <param name="specifications">is a list of view definitions defining the chain of views.</param>
        /// <exception cref="ViewProcessingException">indicating that the view chain configuration is invalid</exception>
        internal static void AddMergeViews(IList <ViewSpec> specifications)
        {
            if (Log.IsDebugEnabled)
            {
                Log.Debug(".addMergeViews Incoming specifications=" + specifications.Render());
            }

            // A grouping view requires a merge view and cannot be last since it would not group sub-views
            if (specifications.Count > 0)
            {
                var lastView = specifications[specifications.Count - 1];
                var viewEnum = ViewEnumExtensions.ForName(lastView.ObjectNamespace, lastView.ObjectName);
                if ((viewEnum != null) && (viewEnum.Value.GetMergeView() != null))
                {
                    throw new ViewProcessingException(
                              "Invalid use of the '" +
                              lastView.ObjectName +
                              "' view, the view requires one or more child views to group, or consider using the group-by clause");
                }
            }

            var mergeViewSpecs = new LinkedList <ViewSpec>();

            foreach (var spec in specifications)
            {
                var viewEnum = ViewEnumExtensions.ForName(spec.ObjectNamespace, spec.ObjectName);
                if (viewEnum == null)
                {
                    continue;
                }

                var mergeView = viewEnum.Value.GetMergeView();
                if (mergeView == null)
                {
                    continue;
                }

                // The merge view gets the same parameters as the view that requires the merge
                var mergeViewSpec = new ViewSpec(
                    mergeView.Value.GetNamespace(), mergeView.Value.GetName(),
                    spec.ObjectParameters);

                // The merge views are added to the beginning of the list.
                // This enables group views to stagger ie. Marketdata.Group("symbol").Group("feed").xxx.Merge(...).Merge(...)
                mergeViewSpecs.AddFirst(mergeViewSpec);
            }

            specifications.AddAll(mergeViewSpecs);

            if (Log.IsDebugEnabled)
            {
                Log.Debug(".addMergeViews Outgoing specifications=" + specifications.Render());
            }
        }
예제 #23
0
        public void AddAll(ExprNodePropOrStreamSet other)
        {
            if (other._properties != null) {
                AllocateProperties();
                _properties.AddAll(other._properties);
            }

            if (other._expressions != null) {
                AllocateExpressions();
                _expressions.AddAll(other._expressions);
            }
        }
예제 #24
0
 private void GetAllRelationships(MessagePart part, IList <Relationship> relationships)
 {
     relationships.AddAll(part.Relationships);
     foreach (SpecializationChild childType in part.SpecializationChilds)
     {
         if (TypeIsAssignable(childType.Name))
         {
             MessagePart childPart = GetService().GetMessagePart(GetVersion(), childType.Name);
             GetAllRelationships(childPart, relationships);
         }
     }
 }
예제 #25
0
 private static void AdjustNumberOfContentLines(IList <LineRenderer> lines, Rectangle bBox, int linesNumber,
                                                float height)
 {
     bBox.MoveUp(bBox.GetHeight() - height);
     bBox.SetHeight(height);
     if (lines.Count > linesNumber)
     {
         IList <LineRenderer> subList = new List <LineRenderer>(lines.SubList(0, linesNumber));
         lines.Clear();
         lines.AddAll(subList);
     }
 }
예제 #26
0
 public static void Reverse <T>(IList <T> list)
 {
     if (list is List <T> )
     {
         ((List <T>)list).Reverse();
     }
     else
     {
         IEnumerable <T> rev = list.Reverse();
         list.Clear();
         list.AddAll(rev);
     }
 }
예제 #27
0
 public static void Sort(IList <String> list, IComparer <String> comparer)
 {
     if (list is List <String> )
     {
         SortUtil.MergeSort((List <String>)list, comparer);
     }
     else
     {
         IEnumerable <String> sorted = list.ToArray().OrderBy(x => x, comparer ?? new SortUtil.StringOrdinalComparator());
         list.Clear();
         list.AddAll(sorted);
     }
 }
예제 #28
0
 public static void Sort <T>(IList <T> list, IComparer <T> comparer)
 {
     if (list is List <T> )
     {
         SortUtil.MergeSort((List <T>)list, comparer);
     }
     else
     {
         IEnumerable <T> sorted = list.ToArray().OrderBy(x => x, comparer ?? Comparer <T> .Default);
         list.Clear();
         list.AddAll(sorted);
     }
 }
예제 #29
0
 public IList<TouchEvent> getTouchEvents()
 {
     lock (this)
     {
         int len = touchEvents.Size();
         for (int i = 0; i < len; i++)
             touchEventPool.free(touchEvents.Get(i));
         touchEvents.Clear();
         touchEvents.AddAll(touchEventsBuffer);
         touchEventsBuffer.Clear();
         return touchEvents;
     }
 }
        public static void OnlyUseSingleOutput(IList <TransactionOutput> tos, int indexToUse)
        {
            ContractsCommon.NotNull(tos, "tos");
            ContractsCommon.ValidIndex(0, tos.Count, indexToUse, "indexToUse");

            var to = tos[indexToUse];

            tos.Clear();
            tos.AddAll(Enumerable.Repeat(new TransactionOutput {
                Value = -1
            }, indexToUse));
            tos.Add(to);
        }
예제 #31
0
 void TryListViewAsSCIList1(IList<B> mylist)
 {
     B b1_ = new B(), b2_ = new B();
       C c1_ = new C(), c2_ = new C();
       mylist.AddAll(new B[] { new B(), b1_, b2_, c1_, new B() });
       System.Collections.IList list = mylist.View(1, 3);
       Object b1 = b1_, b2 = b2_, c1 = c1_, c2 = c2_;
       // Should be called with a three-element view on ArrayList<B>
       Assert.AreEqual(3, list.Count);
       Assert.IsFalse(list.IsSynchronized);
       Assert.AreNotEqual(null, list.SyncRoot);
       Assert.AreEqual(list.SyncRoot, mylist.SyncRoot);
       Assert.IsTrue(list.Contains(b1));
       Assert.IsTrue(list.Contains(b2));
       Assert.IsTrue(list.Contains(c1));
       Assert.IsFalse(list.Contains(c2));
       Array arrA = new A[3], arrB = new B[3];
       list.CopyTo(arrA, 0);
       list.CopyTo(arrB, 0);
       Assert.AreEqual(b1, arrA.GetValue(0));
       Assert.AreEqual(b1, arrB.GetValue(0));
       Assert.AreEqual(b2, arrA.GetValue(1));
       Assert.AreEqual(b2, arrB.GetValue(1));
       Assert.AreEqual(0, list.IndexOf(b1));
       Assert.AreEqual(-1, list.IndexOf(c2));
 }
        public static void OnlyUseSingleOutput(IList<TransactionOutput> tos, int indexToUse)
        {
            ContractsCommon.NotNull(tos, "tos");
            ContractsCommon.ValidIndex(0, tos.Count, indexToUse, "indexToUse");

            var to = tos[indexToUse];
            tos.Clear();
            tos.AddAll(Enumerable.Repeat(new TransactionOutput { Value = -1 }, indexToUse));
            tos.Add(to);
        }