Example #1
1
		public override void Filter(IList<ContentItem> items)
		{
			while (items.Count > maxCount + startIndex)
				items.RemoveAt(items.Count - 1);
			while (items.Count > maxCount)
				items.RemoveAt(0);
		}
 private void ModifyListForTest(IList<string> list)
 {
     list[0] = "OneModified";
     list.Insert(0, "Zero");
     list.RemoveAt(0);
     list.Insert(0, "ZeroAgain");
     list.Insert(4, "Four");
     list.RemoveAt(4);
     list.Insert(4, "FourAgain");
 }
        protected void BindQuestion()
        {
            queslist = CY.CSTS.Core.Business.Question.GetSqlWhere("[IsHomePage]=1");
            unsolvequestion = new List<CY.CSTS.Core.Business.Question>();

            for (int i = 0; i <= queslist.Count - 1; i++)
            {
                if (!isanswer(queslist.ElementAt(i).Id))
                {
                    unsolvequestion.Add(queslist.ElementAt(i));

                }

            }

            for (int i = queslist.Count - 1; i >= 0; i--)
            {
                if (!isanswer(queslist.ElementAt(i).Id))
                {
                    queslist.RemoveAt(i);
                }

            }
            if (queslist.Count >= 4)
            {
                for (int i = queslist.Count - 1; i >= 4; i--)
                {
                    queslist.RemoveAt(i);
                }
            }
            for (int i = 0, j = queslist.Count; i < j; i++)
            {
                //queslist[i].Title = CY.Utility.Common.StringUtility.CutString(queslist[i].Title, 80, "...");
            }

            //Questionlist.DataSource = queslist;
            //Questionlist.DataBind();

            if (unsolvequestion.Count >= 4)
            {
                for (int i = unsolvequestion.Count - 1; i >= 4; i--)
                {
                    unsolvequestion.RemoveAt(i);
                }
            }
            for (int i = 0, j = unsolvequestion.Count; i < j; i++)
            {
                //unsolvequestion[i].Title = CY.Utility.Common.StringUtility.CutString(unsolvequestion[i].Title, 80, "...");
            }
        }
        /// <summary>
        /// Fill bigger time into scheduleList first, until there is no time smaller than [morning/afternoon]TimeLeft
        /// </summary>
        /// <param name="requests"></param>
        /// <returns></returns>
        public override IEnumerable<DaySchedule> Schedule(IList<ScheduleItem> requests)
        {
            if (requests.Count == 0) return null;

            List<DaySchedule> scheduleList = new List<DaySchedule>();

            while (requests.Count > 0)
            {
                DaySchedule daySchedule = new DaySchedule();
                // Schedule morning meeting
                int moringTimeLeft=ConfigurationSetting.MorningDuration;
                for (int i = requests.Count-1; i >=0; i--)
                {
                    if (requests[i].ScheduleTime == moringTimeLeft)
                    {
                        daySchedule.MorningPlan.Add(requests[i]);
                        requests.RemoveAt(i);
                        break;
                    }
                    else if (requests[i].ScheduleTime < moringTimeLeft)
                    {
                        daySchedule.MorningPlan.Add(requests[i]);
                        moringTimeLeft -= requests[i].ScheduleTime;
                        requests.RemoveAt(i);
                    }
                }

                // Schedule afternoon meeting
                int afternoonTimeLeft = ConfigurationSetting.AfternoonDuration;
                for (int i = requests.Count - 1; i >= 0; i--)
                {
                    if (requests[i].ScheduleTime == afternoonTimeLeft)
                    {
                        daySchedule.AfternoonPlan.Add(requests[i]);
                        requests.RemoveAt(i);
                        break;
                    }
                    else if (requests[i].ScheduleTime < afternoonTimeLeft)
                    {
                        daySchedule.AfternoonPlan.Add(requests[i]);
                        afternoonTimeLeft -= requests[i].ScheduleTime;
                        requests.RemoveAt(i);
                    }
                }

                scheduleList.Add(daySchedule);
            }

            return scheduleList;
        }
 /// <summary>
 /// Deletes the employee
 /// </summary>
 public override void Perform(IList<Employee> employees, IEnumerable<Employee> query, StringBuilder log)
 {
     var employee = employees[Index];
     employees.RemoveAt(Index);
     log.AppendFormat("Delete Employee {0}", employee.Name);
     log.AppendLine();
 }
 public static void RotateRight(IList sequence, int count)
 {
     //This method makes a swap of the list elements to the right
     object tmp = sequence[count - 1];
     sequence.RemoveAt(count - 1);
     sequence.Insert(0, tmp);
 }
        public override void Draw(
			IList<Point> points,
			double thickness,
			int miterLimit,
			ILogicalToScreenMapper logicalToScreenMapper)
        {
            // First define the geometric shape
            var streamGeometry = new StreamGeometry();
            using (var gc = streamGeometry.Open())
            {
                gc.BeginFigure(points[0], _fillAndClose, _fillAndClose);
                points.RemoveAt(0);

                gc.PolyLineTo(points, true, true);
            }

            using (var dc = RenderOpen())
                dc.DrawGeometry(
                    _fillAndClose ? Brushes.White : null,
                    new Pen(
                        Brushes.White,
                        thickness == 1 ? 0.25 : thickness)
                        {
                            MiterLimit = miterLimit
                        },
                    streamGeometry);
        }
Example #8
1
        public IList<string> FixExpressions(IList<string> expressions)
        {
            expressions = RemoveEmptyExpressions(expressions);

            var listHasChanged = true;
            while (listHasChanged)
            {
                listHasChanged = false;
                for (var i = 0; i < expressions.Count; i++)
                {
                    var exp = expressions[i];
                    if (!this.expressionValidator.IsNumberAndOperator(exp)) continue;
                    var splitted = RemoveEmptyExpressions(SplitByOperator(exp));
                    expressions.RemoveAt(i);

                    foreach (var newExp in splitted)
                    {
                        expressions.Add(newExp.Trim());
                        i++;
                    }
                    listHasChanged = true;
                }
            }
            return expressions;
        }
        override protected void Process(IFCAnyHandle ifcPolyLoop)
        {
            base.Process(ifcPolyLoop);

            List<IFCAnyHandle> ifcPolygon = 
                IFCAnyHandleUtil.GetAggregateInstanceAttribute<List<IFCAnyHandle>>(ifcPolyLoop, "Polygon");
            
            if (ifcPolygon == null)
                return; // TODO: WARN

            Polygon = IFCPoint.ProcessScaledLengthIFCCartesianPoints(ifcPolygon);

            int numVertices = Polygon.Count;
            if (numVertices > 1)
            {
                if (Polygon[0].IsAlmostEqualTo(Polygon[numVertices - 1]))
                {
                    // LOG: Warning: #: First and last points are almost identical, removing extra point.
                    Polygon.RemoveAt(numVertices - 1);
                    numVertices--;
                }
            }

            if (numVertices < 3)
                throw new InvalidOperationException("#" + ifcPolyLoop.StepId + ": Polygon attribute has only " + numVertices + " vertices, 3 expected.");
        }
Example #10
1
 private void CheckFirstAndLastPoint(IList<Point> points)
 {
     if (this.DistanceIsTooSmall(points.Last(), points.First()))
     {
         points.RemoveAt(points.Count - 1);
     }
 }
 ///////////////////////////////////////////////////////////////////////
 /// <summary>Replaces or adds an extension of the given type
 /// to the list.
 ///
 /// This method looks for the first element on the list of the
 /// given type and replaces it with the new value. If there are
 /// no element of this type yet, a new element is added at the
 /// end of the list.
 /// </summary>
 /// <param name="extensionElements">list of IExtensionElement</param>
 /// <param name="type">type of the element to be added, removed
 /// or replaced</param>
 /// <param name="newValue">new value for this element, null to
 /// remove it</param>
 ///////////////////////////////////////////////////////////////////////
 public static void SetExtension(IList<IExtensionElementFactory> extensionElements,
                                 Type type,
                                 IExtensionElementFactory newValue)
 {
     int count = extensionElements.Count;
     for (int i = 0; i < count; i++)
     {
         object element = extensionElements[i];
         if (type.IsInstanceOfType(element))
         {
             if (newValue == null)
             {
                 extensionElements.RemoveAt(i);
             }
             else
             {
                 extensionElements[i] = newValue;
             }
             return;
         }
     }
     if (newValue != null)
     {
         extensionElements.Add(newValue);
     }
 }
Example #12
1
 private void Search(Dictionary<int, int> count, IList<int> temp, IList<IList<int>> results)
 {
     if (!count.Any() && temp.Any())
     {
         results.Add(new List<int>(temp));
         return;
     }
     var keys = count.Keys.ToList();
     foreach (var key in keys)
     {
         temp.Add(key);
         --count[key];
         if (count[key] == 0) count.Remove(key);
         Search(count, temp, results);
         temp.RemoveAt(temp.Count - 1);
         if (count.ContainsKey(key))
         {
             ++count[key];
         }
         else
         {
             count[key] = 1;
         }
     }
 }
		public void AssignFragmentPeak(IList<IAtomContainer> fragments, IEnumerable<Peak> peakList, double mzabs, double mzppm)
		{
			hits = new List<PeakMolPair>();
			hitsAll = new List<PeakMolPair>();			

			foreach (var peak in peakList)
			{
				var haveFoundAMatch = false;
				foreach (var fragment in fragments)
				{
					//matched peak
					int hydrogensAdded;
					double matchedMass;
					double hydrogenPenalty;
					if (MatchByMass(fragment, peak.Mass, mzabs, mzppm, out matchedMass, out hydrogenPenalty, out hydrogensAdded))
					{
                        var match = new PeakMolPair(fragment, peak, matchedMass, GetMolecularFormulaAsString(fragment), hydrogenPenalty, double.Parse((string)fragment.getProperty("BondEnergy"), CultureInfo.InvariantCulture), GetNeutralChange(fragment, hydrogensAdded));
						hitsAll.Add(match);

						// If we don't yet have a match, add it
						if (!haveFoundAMatch)
						{
							hits.Add(match);
							haveFoundAMatch = true;
						}
						// If we do have a match, replace it if this new match has a lower hydrogen penalty
						else if (hydrogenPenalty < hits.Last().HydrogenPenalty)
						{
							hits.RemoveAt(hits.Count - 1);
							hits.Add(match);
						}						
					}
				}
			}
		}
 private void CheckFirstAndLastPoint(IList<DepthPointEx> points)
 {
     if (PointsAreClose(points.Last(), points.First()))
     {
         points.RemoveAt(points.Count - 1);
     }
 }
        public int BatchSave(IList<MsgRecord> msgRecords)
        {
            #region prevent duplicate data
            IList<string> msgids=new List<string>();

            for(int i=0;i<msgRecords.Count;i++)
            {
                msgids.Add(msgRecords[i].MsgID);
            }

            var query = from aa in msgRecordRepository.Table
                        join bb in msgids on aa.MsgID equals bb
                        select aa.MsgID;
            IList<string> tempids = query.ToList();
            #endregion

            for (int i = msgRecords.Count-1; i >= 0; i--)
            {
                if(tempids.Contains(msgRecords[i].MsgID))
                {
                    msgRecords.RemoveAt(i);
                }
            }

            return msgRecordRepository.BatchInsert(msgRecords);
        }
Example #16
1
        public static IList<int> Merge(IList<int> left, IList<int> right)
        {
            IList<int> result = new List<int>();

            while (left.Any() && right.Any())
            {
                if (left[0] < right[0])
                {
                    result.Add(left[0]);
                    left.Remove(left[0]);
                }
                else
                {
                    result.Add(right[0]);
                    right.Remove(right[0]);
                }
            }

            while (left.Any())
            {
                result.Add(left[0]);
                left.RemoveAt(0);
            }
            while (right.Any())
            {
                result.Add(right[0]);
                right.RemoveAt(0);
            }

            return result;
        }
        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
        {
            SnapshotPoint? point = session.GetTriggerPoint(_buffer.CurrentSnapshot);
            if (!point.HasValue)
                return;

            CssEditorDocument document = CssEditorDocument.FromTextBuffer(_buffer);
            ParseItem item = document.StyleSheet.ItemBeforePosition(point.Value.Position);

            if (item == null)
                return;

            Declaration dec = item.FindType<Declaration>();
            if (dec == null || dec.PropertyName == null || dec.Colon == null)
                return;

            foreach (ISignature signature in signatures)
            {
                if (signature is ValueOrderSignature)
                {
                    signatures.RemoveAt(signatures.Count - 1);
                    break;
                }
            }
        }
Example #18
0
        public static IList Merge(IList left, IList right)
        {
            IList rv = new ArrayList();

            while (left.Count > 0 && right.Count > 0)
            {
                if (((IComparable)left[0]).CompareTo(right[0]) > 0)
                {
                    rv.Add(right[0]);
                    right.RemoveAt(0);
                }
                else
                {
                    rv.Add(left[0]);
                    left.RemoveAt(0);
                }
            }

            for (int i = 0; i < left.Count; i++)
                rv.Add(left[i]);

            for (int i = 0; i < right.Count; i++)
                rv.Add(right[i]);

            return rv;
        }
Example #19
0
        public static IList<int> Sort(IList<int> input)
        {
            var rnd = new Random();

            IList<int> less = new List<int>();
            IList<int> greater = new List<int>();

            if (input.Count <= 1)
            {
                return input;
            }

            var pos = rnd.Next(input.Count);
            var pivot = input[pos];

            input.RemoveAt(pos);

            foreach (var i in input)
            {
                if (i <= pivot)
                {
                    less.Add(i);
                }
                else
                {
                    greater.Add(i);
                }
            }

            //less = Sort(less);
            //greater = Sort(greater);
            //return Concat(less, pivot, greater);
            return Concat(Sort(less), pivot, Sort(greater));
        }
Example #20
0
 public bool SignalExternalCommandLineArgs(IList<string> args)
 {
     args.RemoveAt(0); //Removes the executable file name
     cmdLineResult = Parser.Default.ParseArguments<Options>(args.ToArray());
     ParseArguments();
     return true;
 }
        void SweepAttributes(IList<CustomAttribute> attributes)
        {
            for (int i = 0; i < attributes.Count; i++) {
                var ca = attributes [i];

                // we do not have to keep IVT to assemblies that are not part of the application
                if (!ca.AttributeType.Is ("System.Runtime.CompilerServices", "InternalsVisibleToAttribute"))
                    continue;

                // validating the public key and the public key token would be time consuming
                // worse case (no match) is that we keep the attribute while it's not needed
                var fqn = (ca.ConstructorArguments [0].Value as string);
                int pk = fqn.IndexOf (", PublicKey=", StringComparison.OrdinalIgnoreCase);
                if (pk != -1)
                    fqn = fqn.Substring (0, pk);

                bool need_ivt = false;
                foreach (var assembly in Context.GetAssemblies ()) {
                    if (assembly.Name.Name == fqn) {
                        need_ivt = true;
                        break;
                    }
                }
                if (!need_ivt)
                    attributes.RemoveAt (i--);
            }
        }
Example #22
0
        static IList<int> Sort(IList<int> input)
        {
            if (input.Count <= 1)
            {
                return input;
            }

            IList<int> less = new List<int>();
            IList<int> greater = new List<int>();

            var rnd = new Random();

            var pivotPos = rnd.Next(input.Count);
            var pivot = input[pivotPos];

            input.RemoveAt(pivotPos);

            foreach (var i in input)
            {
                if (i < pivot)
                {
                    less.Add(i);
                }
                else
                {
                    greater.Add(i);
                }
            }

            less = Sort(less);
            greater = Sort(greater);

            return Concat(less,pivot, greater);
        }
Example #23
0
        public object GetArg(IList<string> args)
        {
            if(args.Count == 0)
                throw new Exception("too few arguments");

            var first = args.FirstOrDefault();

            var projectFilename = ZMFile.DefaultFilename;

            if (first.EndsWith(".zm"))
            {
                projectFilename = first;
                args.RemoveAt(0);
            }

            var targets = args.Where(x => !x.StartsWith("{")).ToList();
            var parameterString = args.FirstOrDefault(x => x.StartsWith("{")) ?? string.Empty;
            var parameters = new JObject();

            if(!string.IsNullOrWhiteSpace(parameterString))
                parameters = JObject.Parse(parameterString);

            var result = new RunArg(projectFilename, targets, parameters);
            return result;
        }
Example #24
0
        private void ReplayChanges(IndividualCollectionChange change, IList ilist)
        {
            CefCoreSessionSingleton.Session.Dispatcher.Run(() =>
            {
                switch (change.CollectionChangeType)
                {
                    case CollectionChangeType.Add:
                    if (change.Index == ilist.Count)
                    {
                        ilist.Add(change.Object.CValue);
                        Items.Add(change.Object);
                    }
                    else
                    {
                        ilist.Insert(change.Index, change.Object.CValue);
                        Items.Insert(change.Index, change.Object);
                    }
                    break;

                    case CollectionChangeType.Remove:
                        ilist.RemoveAt(change.Index);
                        Items.RemoveAt(change.Index);
                    break;
                }
            });
        }
        public Expression Parse(IList<Token> tokens)
        {
            if (tokens.Count > 1 && tokens[0].Type == Symbol.Subtract)
            {
                if (tokens[1].Type == Symbol.Number)
                {
                    tokens.RemoveAt(0);

                    double num = double.Parse(tokens[0].Value);
                    num *= -1;

                    tokens[0].Value = num.ToString();
                }
                else
                {
                    tokens[0].Type = Symbol.Number;
                    tokens[0].Value = "-1";

                    tokens.Insert(1, new Token(Symbol.Multiply));
                }
            }

            int index = 0;

            return sums(tokens, ref index);
        }
 protected override void ProcessAssemblyReferences(ModuleDefinition moduleDef, IList<AssemblyNameReference> assemblyNameRefs)
 {
     for (int i = assemblyNameRefs.Count - 1; i >= 0; --i) {
         AssemblyNameReference replacement = null;
         var other = assemblyNameRefs[i];
         var otherName = other.Name + "," + other.Version;
         if (_assemblyReplacements.TryGetValue(other.Name, out replacement)) {
             assemblyNameRefs[i].Version = replacement.Version;
             assemblyNameRefs[i].PublicKeyToken = replacement.PublicKeyToken;
             assemblyNameRefs[i].IsRetargetable = replacement.IsRetargetable;
             var replacementName = replacement.Name + "," + replacement.Version;
             Trace.WriteLine(string.Format("Replacing {0} with {1}.", otherName, replacementName), "RetargetReferences");
         } else {
             if (_removeOthers) {
                 try {
                     var otherAss = moduleDef.AssemblyResolver.Resolve(other);
                     var otherProfile = otherAss.GetAssemblyProfileFromAttribute();
                     if (otherProfile != null && otherProfile.IsPortable) {
                         Trace.WriteLine(string.Format("Keeping {0}.", otherName), "RetargetReferences");
                         continue;
                     }
                 } catch(Exception ex) {
                     Trace.WriteLine(string.Format("Failed resolving {0}.", otherName), "RetargetReferences");
                 }
                 Trace.WriteLine(string.Format("Removing {0}.", otherName), "RetargetReferences");
                 assemblyNameRefs.RemoveAt(i);
             } else {
                 Trace.WriteLine(string.Format("Keeping {0}.", otherName), "RetargetReferences");
             }
         }
     }
     base.ProcessAssemblyReferences(moduleDef, assemblyNameRefs);
 }
Example #27
0
        protected void bindbooklist()
        {
            booklist = CY.GFive.Core.Business.BookSchedule.GetAll();

            if (booklist != null)
            {
                for (int i = booklist.Count-1; i>=0; i--)
                {
                    if (booklist.ElementAt(i).Result == 2)
                    {
                        unarrivebook.Add(booklist.ElementAt(i));
                        if (booklist.ElementAt(i).Days <= 5)
                        {
                            warninglist.Add(booklist.ElementAt(i));
                        }
                        booklist.RemoveAt(i);

                    }
                }
            }
            WarnList.DataSource=warninglist;
            WarnList.DataBind();
            UnarrivBookList.DataSource = unarrivebook;
            UnarrivBookList.DataBind();
            ArrivBooklist.DataSource = booklist;
            ArrivBooklist.DataBind();
        }
Example #28
0
        private static IList findAllFromChild( IList parents, ObjectInfo state ) {

            ArrayList results = new ArrayList();

            foreach (EntityInfo info in state.EntityInfo.ChildEntityList) {

                ObjectInfo childState = new ObjectInfo( info);
                childState.includeAll();
                IList children = ObjectDb.FindAll( childState );

                for (int i = 0; i < children.Count; i++) {
                    IEntity child = children[i] as IEntity;
                    // state
                    //child.state.Order = state.Order;
                    results.Add( child );
                    parents.RemoveAt( Query.getIndexOfObject( parents, child ) );
                }

            }

            if (parents.Count > 0) results.AddRange( parents );
            results.Sort();

            return results;
        }
Example #29
0
        public void bindquestion(IList<CY.CSTS.Core.Business.Question> list ,int pagenum)
        {
            for (int i = list.Count - 1; i >= 0; i--)
            {
                bool isnum = getanswernum(list.ElementAt(i).Id);
                if (!isnum)
                {
                    list.RemoveAt(i);
                }

            }

            PagedDataSource ps = new PagedDataSource();
            ps.DataSource =list;
            ps.AllowPaging = true;
            ps.PageSize = 10;
            TotalPage.Text = ps.PageCount.ToString();
            ShowPage.Text = pagenum.ToString();
            ps.CurrentPageIndex = pagenum-1;
            Pageup.Enabled = true;
            Pagedown.Enabled = true;

            if ((pagenum-1) == 0)
            {
                this.Pageup.Enabled = false;

            }
            if (pagenum == ps.PageCount)
            {
                this.Pagedown.Enabled = false;

            }
            QuesList.DataSource = ps;
            QuesList.DataBind();
        }
Example #30
0
 protected override void ApplyToSpecificElement(ref int index, IList<IElement> elements, Stack<BranchStackFrame> branchStack, DecompilationContext context)
 {
     var instruction = elements[index] as InstructionElement;
     if (instruction != null && instruction.OpCode == OpCodes.Nop) {
         elements.RemoveAt(index);
         index -= 1;
     }
 }