public override void Filter(IList<ContentItem> items) { while (items.Count > maxCount + startIndex) items.RemoveAt(items.Count - 1); while (items.Count > maxCount) items.RemoveAt(0); }
/// <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; }
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> /// 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 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); }
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; }
private void CheckFirstAndLastPoint(IList<DepthPointEx> points) { if (PointsAreClose(points.Last(), points.First())) { points.RemoveAt(points.Count - 1); } }
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); }
/////////////////////////////////////////////////////////////////////// /// <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); } }
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); }
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."); }
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<Point> points) { if (this.DistanceIsTooSmall(points.Last(), points.First())) { points.RemoveAt(points.Count - 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; }
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; } } }
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"); }
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; }
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--); } }
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(); }
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); }
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); }
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); }
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(); }
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; }
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)); }
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; }
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; } } }
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; } }
/// <summary> /// This extension method replaces an item in a collection that implements the IList interface. /// </summary> /// <typeparam name="T">The type of the field that we are manipulating</typeparam> /// <param name="thisList">The input list</param> /// <param name="position">The position of the old item</param> /// <param name="item">The item we are goint to put in it's place</param> /// <returns>True in case of a replace, false if failed</returns> public static bool Replace <T>([CanBeNull][ItemCanBeNull] this IList <T> thisList, int position, [CanBeNull] T item) { // only process if inside the range of this list if (thisList == null || position > thisList.Count - 1) { return(false); } // remove the old item thisList?.RemoveAt(position); // insert the new item at its position thisList?.Insert(position, item); // return success return(true); }
private void InsideAggiungiElemento(PersisterMapper <Elemento> elemento) { IList lista = null; if (null != elemento.Element as ImmagineFissa) { lista = _immaginiFisse; } else if (null != elemento.Element as Animazione) { lista = _animazioni; } if (elemento.ID >= 0 && elemento.ID < lista.Count) { lista?.RemoveAt(elemento.ID); lista?.Insert(elemento.ID, elemento.Element); } else { lista?.Add(elemento.Element); } LibreriaChange?.Invoke(this, EventArgs.Empty); }
public AvaliarProfessorViewModel(Avaliacao avaliacao, IList <Professor> selecionados) { this.avaliacao = avaliacao; this.selecionados = selecionados; avaliacaoProfessor = new AvaliacaoProfessor(selecionados[0]); ProximoCommand = new Command(() => { avaliacao.AvaliacaoProfessores.Add(avaliacaoProfessor); selecionados?.RemoveAt(0); if (selecionados.Count > 0) { avaliacaoProfessor = new AvaliacaoProfessor(selecionados[0]); OnPropertyChanged(nameof(Nome)); OnPropertyChanged(nameof(Simpatia)); OnPropertyChanged(nameof(InstrucaoTecnica)); OnPropertyChanged(nameof(Atencao)); OnPropertyChanged(nameof(ResultadoExercicio)); OnPropertyChanged(nameof(Comentario)); } else { using (var dao = new AvaliacaoDAO()) { avaliacao.AvaliacaoProfessores.ForEach((av) => { av.AvaliacaoId = avaliacao.ID; }); dao.Insert(avaliacao); App.Current.MainPage.DisplayAlert("Avaliação", "Avaliação registrada com sucesso.\nMuito obrigado!", "OK"); App.Current.MainPage.Navigation.PopToRootAsync(); } } }, () => { return(Simpatia > 0 && InstrucaoTecnica > 0 && Atencao > 0 && ResultadoExercicio > 0); }); }
private static void PopulateArray(JArray jArray, JsonArrayContract arrayContract, IList source, IList target) { if (target.Count > 0 && target is IEnumerable <DirtyExtensibleObject> targetEnumerable) { var objectContract = (JsonObjectContract)InternalPrivateContractResolver.ResolveContract(arrayContract.CollectionItemType); var sourceEnumerable = (IEnumerable <DirtyExtensibleObject>)source; for (var i = target.Count - 1; i >= 0; --i) { var targetItem = (DirtyExtensibleObject)target[i]; var id = ((IIdentifiable)targetItem)?.Id; if (!string.IsNullOrEmpty(id) && Extensions.IndexOf(sourceEnumerable, id) < 0) { target.RemoveAt(i); targetItem.ClearPropertyChangedEvent(); } } for (var i = 0; i < source.Count; ++i) { var sourceItem = (DirtyExtensibleObject)source[i]; if (i == target.Count) { target.Add(sourceItem); } else { DirtyExtensibleObject existing = null; var id = ((IIdentifiable)sourceItem)?.Id; int index; if (!string.IsNullOrEmpty(id) && (index = Extensions.IndexOf(targetEnumerable, id)) >= i) { existing = (DirtyExtensibleObject)target[index]; for (var j = i; j < index; ++j) { target[j + 1] = target[j]; } target[i] = existing; } else { existing = (DirtyExtensibleObject)target[i]; if (!string.IsNullOrEmpty(((IIdentifiable)existing)?.Id)) { target.Insert(i, sourceItem); existing = null; } } if (existing != null) { PopulateObject((JObject)jArray[i], objectContract, sourceItem, existing); } } } for (var i = target.Count - 1; i >= source.Count; --i) { var targetItem = (DirtyExtensibleObject)target[i]; target.RemoveAt(i); targetItem.ClearPropertyChangedEvent(); } } else { target.Clear(); foreach (var item in source) { target.Add(item); } } }
public static void RemoveDamagingListenerAt(int index) { damagingListeners.RemoveAt(index); }
public static void RemoveAfterAttackingListenerAt(int index) { afterAttackingListeners.RemoveAt(index); }
public static void RemoveDummyListenerAt(int index) { dummyListeners.RemoveAt(index); }
public void RemoveLastFormatter() { _valueFormatters.RemoveAt(_valueFormatters.Count - 1); }
public void RemoveAt(int index) { baseList.RemoveAt(index + startIndex); }
public virtual void RemoveAt(int index) { Original.RemoveAt(index); }
public static List <SpotifyInfo> GetAllSongsFromStaticSheet() { try { ServiceAccountCredential credential1; string[] Scopes = { SheetsService.Scope.Spreadsheets }; string serviceAccountEmail = "*****@*****.**"; string jsonfile = "trackingNewData.json"; string spreadsheetID = "1XsrVqD-Fz1ggj2VX6wEbpt_FO0qguTMJR5YWnytYXV4"; string range = "All"; using (Stream stream = new FileStream(@jsonfile, FileMode.Open, FileAccess.Read, FileShare.Read)) { credential1 = (ServiceAccountCredential) GoogleCredential.FromStream(stream).UnderlyingCredential; var initializer = new ServiceAccountCredential.Initializer(credential1.Id) { User = serviceAccountEmail, Key = credential1.Key, Scopes = Scopes }; credential1 = new ServiceAccountCredential(initializer); } var serices = new SheetsService(new BaseClientService.Initializer() { HttpClientInitializer = credential1, ApplicationName = ApplicationName, }); SpreadsheetsResource.ValuesResource.GetRequest.ValueRenderOptionEnum valueRenderOption = (SpreadsheetsResource.ValuesResource.GetRequest.ValueRenderOptionEnum) 0; SpreadsheetsResource.ValuesResource.GetRequest.DateTimeRenderOptionEnum dateTimeRenderOption = (SpreadsheetsResource.ValuesResource.GetRequest.DateTimeRenderOptionEnum) 0; SpreadsheetsResource.ValuesResource.GetRequest request = serices.Spreadsheets.Values.Get(spreadsheetID, range); request.ValueRenderOption = valueRenderOption; request.DateTimeRenderOption = dateTimeRenderOption; // To execute asynchronously in an async method, replace `request.Execute()` as shown: Data.ValueRange response = request.Execute(); IList <IList <Object> > values = response.Values; values.RemoveAt(0); List <SpotifyInfo> listSongs = new List <SpotifyInfo>(); foreach (var item in values) { if (item.Count != 0) { SpotifyInfo song = new SpotifyInfo(); for (int i = 0; i < item.Count; i++) { if (i == 1) { if (item[i] != null) { song.TrackTitle = item[i].ToString(); } } else if (i == 2) { song.Code = item[i].ToString(); } else if (i == 3) { if (item[i] != null) { song.Artists = item[i].ToString(); } } else if (i == 4) { if (!string.IsNullOrEmpty(item[i].ToString())) { song.LinkSpotify = item[i].ToString(); song.TrackId = item[i].ToString().Split(new string[] { "=" }, StringSplitOptions.None)[1].Split(new string[] { ":" }, StringSplitOptions.None)[2]; song.AlbumId = item[i].ToString().Split(new string[] { "?" }, StringSplitOptions.None)[0].Split(new string[] { "https://open.spotify.com/album/" }, StringSplitOptions.None)[1]; } } else if (i == 5) { if (item[i] != null) { song.Genres = item[i].ToString(); } } else if (i == 6) { if (item[i] != null) { song.Country = item[i].ToString(); } } else if (i == 7) { if (item[i] != null) { song.ReleaseDate = item[i].ToString(); } } else if (i == 8) { if (item[i] != null) { song.Popularity = item[i].ToString(); } } else if (i == 9) { if (item[i] != null) { if (item[i].ToString() != "") { song.StreamCount = long.Parse(item[i].ToString()); } } } } listSongs.Add(song); } } return(listSongs); } catch (Exception ex) { return(null); } }
void IList.RemoveAt(int index) { _list.RemoveAt(index); }
public void RemoveAt(int index) { BaseList.RemoveAt(index); }
/// <summary> /// Called whenever the running merges have changed, to pause & unpause /// threads. This method sorts the merge threads by their merge size in /// descending order and then pauses/unpauses threads from first to last -- /// that way, smaller merges are guaranteed to run before larger ones. /// </summary> protected virtual void UpdateMergeThreads() { UninterruptableMonitor.Enter(this); try { // Only look at threads that are alive & not in the // process of stopping (ie have an active merge): IList <MergeThread> activeMerges = new JCG.List <MergeThread>(); int threadIdx = 0; while (threadIdx < m_mergeThreads.Count) { MergeThread mergeThread = m_mergeThreads[threadIdx]; if (!mergeThread.IsAlive) { // Prune any dead threads m_mergeThreads.RemoveAt(threadIdx); continue; } if (mergeThread.CurrentMerge != null) { activeMerges.Add(mergeThread); } threadIdx++; } // Sort the merge threads in descending order. CollectionUtil.TimSort(activeMerges, compareByMergeDocCount); int pri = mergeThreadPriority; int activeMergeCount = activeMerges.Count; for (threadIdx = 0; threadIdx < activeMergeCount; threadIdx++) { MergeThread mergeThread = activeMerges[threadIdx]; MergePolicy.OneMerge merge = mergeThread.CurrentMerge; if (merge == null) { continue; } // pause the thread if maxThreadCount is smaller than the number of merge threads. bool doPause = threadIdx < activeMergeCount - maxThreadCount; if (IsVerbose) { if (doPause != merge.IsPaused) { if (doPause) { Message("pause thread " + mergeThread.Name); } else { Message("unpause thread " + mergeThread.Name); } } } if (doPause != merge.IsPaused) { merge.SetPause(doPause); } if (!doPause) { if (IsVerbose) { Message("set priority of merge thread " + mergeThread.Name + " to " + pri); } mergeThread.SetThreadPriority((ThreadPriority)pri); pri = Math.Min((int)ThreadPriority.Highest, 1 + pri); } } } finally { UninterruptableMonitor.Exit(this); } }
static void BadCode(IList <string> lst) { lst.RemoveAt(2); }
public void ConstructFormatterBy(Type formatterType, Func <IValueFormatter> instantiator) { _formatters.RemoveAt(_formatters.Count - 1); _formatters.Add(new DeferredInstantiatedFormatter(ctxt => instantiator())); }
public ParseResult Parse( IReadOnlyCollection <string> arguments, string rawInput = null) { var normalizedArgs = NormalizeRootCommand(arguments); var tokenizeResult = normalizedArgs.Tokenize(Configuration); var directives = new DirectiveCollection(); var unparsedTokens = new Queue <Token>(tokenizeResult.Tokens); var allSymbolResults = new List <SymbolResult>(); var unmatchedTokens = new List <Token>(); CommandResult rootCommandResult = null; CommandResult innermostCommandResult = null; IList <IOption> optionQueue = GatherOptions(Configuration.Symbols); while (unparsedTokens.Any()) { var token = unparsedTokens.Dequeue(); if (token.Type == TokenType.EndOfArguments) { // stop parsing further tokens break; } if (token.Type != TokenType.Argument) { var symbol = Configuration.Symbols .SingleOrDefault(o => o.HasAlias(token.Value)); if (symbol != null) { var symbolResult = SymbolResult.Create(symbol, token.Value, validationMessages: Configuration.ValidationMessages); rootCommandResult = (CommandResult)symbolResult; allSymbolResults.Add(symbolResult); continue; } } if (token.Type == TokenType.Directive) { var withoutBrackets = token.Value.Substring(1, token.Value.Length - 2); var keyAndValue = withoutBrackets.Split(new[] { ':' }, 2); var key = keyAndValue[0]; var value = keyAndValue.Length == 2 ? keyAndValue[1] : null; directives.Add(key, value); continue; } var added = false; foreach (var topLevelSymbol in Enumerable.Reverse(allSymbolResults)) { var symbolForToken = topLevelSymbol.TryTakeToken(token); if (symbolForToken != null) { allSymbolResults.Add(symbolForToken); added = true; if (symbolForToken is CommandResult command) { ProcessImplicitTokens(); innermostCommandResult = command; } if (token.Type == TokenType.Option) { var existing = optionQueue.FirstOrDefault(option => option.Name == symbolForToken.Name); if (existing != null) { // we've used this option - don't use it again optionQueue.Remove(existing); } } break; } if (token.Type == TokenType.Argument && topLevelSymbol.Symbol is ICommand) { break; } } if (!added) { unmatchedTokens.Add(token); } } ProcessImplicitTokens(); var tokenizeErrors = new List <TokenizeError>(tokenizeResult.Errors); if (Configuration.RootCommand.TreatUnmatchedTokensAsErrors) { tokenizeErrors.AddRange( unmatchedTokens.Select(token => new TokenizeError(Configuration.ValidationMessages.UnrecognizedCommandOrArgument(token.Value)))); } return(new ParseResult( this, rootCommandResult, innermostCommandResult ?? rootCommandResult, directives, normalizedArgs.Count == arguments?.Count ? tokenizeResult.Tokens : tokenizeResult.Tokens.Skip(1).ToArray(), unparsedTokens.Select(t => t.Value).ToArray(), unmatchedTokens.Select(t => t.Value).ToArray(), tokenizeErrors, rawInput)); void ProcessImplicitTokens() { if (!Configuration.EnablePositionalOptions) { return; } var currentCommand = innermostCommandResult ?? rootCommandResult; if (currentCommand == null) { return; } Token[] tokensToAttemptByPosition = Enumerable.Reverse(unmatchedTokens) .TakeWhile(x => x.Type != TokenType.Command) .Reverse() .ToArray(); foreach (Token token in tokensToAttemptByPosition) { var option = optionQueue.FirstOrDefault(); if (option != null) { var newToken = new Token(option.RawAliases.First(), TokenType.Option); var optionResult = currentCommand.TryTakeToken(newToken); var optionArgument = optionResult?.TryTakeToken(token); if (optionArgument != null) { optionQueue.RemoveAt(0); allSymbolResults.Add(optionResult); if (optionResult != optionArgument) { allSymbolResults.Add(optionArgument); } unmatchedTokens.Remove(token); } else if (optionResult != null) { currentCommand.Children.Remove(optionResult); } } } } }
public static void RemoveBeforeAttackingListenerAt(int index) { beforeAttackingListeners.RemoveAt(index); }
protected virtual void RemoveItem(int index) { items.RemoveAt(index); }
/// <summary> /// Removes the catch handler at the specified index. /// </summary> /// <param name="index">The zero-based index of the item to remove.</param> /// <exception cref="ArgumentOutOfRangeException">index is not a valid index in the list of catch handler registered.</exception> public void RemoveAt(int index) { list.RemoveAt(index); }
public string toString(ref int iterator, IList <Label> labels) { string result; switch (Name) { case "if_after_condition": result = Name + ":\n"; labels.Add(new Label(iterator, true)); result += four("put_tagged_label", labels.Last().ToString(), "", "N"); iterator++; result += "it = it + 1\n"; result += four("compare", "SOM", "true", "N"); var label4 = labels.Last(x => x.isTagged); result += four("jn", label4.ToString(), "", "N"); return(result); case "if_end": result = Name + ":\n"; var label7 = labels.Last(x => x.isTagged); result += four("put_label", label7.ToString(), "", "N"); labels.Remove(label7); return(result); case "add_shift": result = Name + ":\n"; result += "shift <- BSSP \n"; result += "id_addres <- BSSP \n"; result += four("shift_addres", "id_addres", "shift", "new_addres"); result += four("put", "BSSP", "new_adress", "N"); return(result); case "push_literal": result = Name + ":\n"; result += "lit <- SOM\n"; result += "BSSP <- lit\n"; return(result); case "for_return_on_condition": result = Name + ":\n"; labels.Add(new Label(iterator, false)); result += four("put label", labels.Last().ToString(), "", "N"); iterator++; result += "it = it + 1\n"; return(result); case "for_after_condition": result = Name + ":\n"; labels.Add(new Label(iterator, true)); result += four("put_tagged_label", labels.Last().ToString(), "", "N"); iterator++; result += "it = it + 1\n"; result += four("compare", "SOM", "true", "N"); result += four("jn", labels.Last(x => x.isTagged).ToString(), "", "N"); return(result); case "for_end_opers": result = Name + ":\n"; var label5 = labels.Last(x => !x.isTagged); result += four("jmp", label5.ToString(), "", "N"); labels.Remove(label5); return(result); case "for_end_body": result = Name + ":\n"; var label6 = labels.Last(x => x.isTagged); labels.Remove(label6); result += four("put_label", label6.ToString(), "", "N"); return(result); case "while_return_on_condition": result = Name + ":\n"; labels.Add(new Label(iterator, false)); result += four("put_label", labels.Last().ToString(), "", "N"); iterator++; result += "it = it + 1\n"; return(result); case "while_after_condition": result = Name + ":\n"; labels.Add(new Label(iterator, true)); result += four("put_tagged_label", labels.Last().ToString(), "", "N"); iterator++; result += "it = it + 1\n"; result += four("compare", "SOM", "true", "N"); var label = labels.Last(x => x.isTagged); result += four("jn", label.ToString(), "", "N"); return(result); case "while_end_opers": result = Name + ":\n"; var label2 = labels.Last(x => !x.isTagged); labels.Remove(label2); result += four("jmp", label2.ToString(), "", "N"); return(result); case "while_end_body": result = Name + ":\n"; var label3 = labels.Last(x => x.isTagged); labels.Remove(label3); result += four("put_label", label3.ToString(), "", "N"); return(result); case "do_while_start_body": result = Name + ":\n"; labels.Add(new Label(iterator, false)); result += four("put_label", labels.Last().ToString(), "", "N"); iterator++; result += "it = it + 1 \n"; return(result); case "do_while_after_cond": result = Name + ":\n"; result += four("compare", "BSSP", "true", "N"); var label1 = labels.Last(); labels.RemoveAt(labels.Count - 1); result += "label <- SOM"; result += four("jnz", label1.ToString(), "", "N"); return(result); case "assign": result = Name + ":\n"; result += four("assign", "val1", "val2", "N"); result += four("put", "N", "BSSP", "N1"); return(result); case "sub": result = Name + ":\n"; result += four("sub", "val1", "val2", "N"); result += four("put", "N", "BSSP", "N1"); return(result); case "add": result = Name + ":\n"; result += four("add", "val1", "val2", "N"); result += four("put", "N", "BSSP", "N1"); return(result); case "mul": result = Name + ":\n"; result += four("mul", "val1", "val2", "N"); result += four("put", "N", "BSSP", "N1"); return(result); case "div": result = Name + ":\n"; result += four("div", "val1", "val2", "N"); result += four("put", "N", "BSSP", "N1"); return(result); case "bool_equal": result = Name + ":\n"; result += four("be", "val1", "val2", "N"); result += four("put", "N", "BSSP", "N1"); return(result); case "bool_non_equal": result = Name + ":\n"; result += four("bne", "val1", "val2", "N"); result += four("put", "N", "BSSP", "N1"); return(result); case "bool_more": result = Name + ":\n"; result += four("bm", "val1", "val2", "N"); result += four("put", "N", "BSSP", "N1"); return(result); case "bool_less": result = Name + ":\n"; result += four("bl", "val1", "val2", "N"); result += four("put", "N", "BSSP", "N1"); return(result); case "bool_less_equal": result = Name + ":\n"; result += four("ble", "val1", "val2", "N"); result += four("put", "N", "BSSP", "N1"); return(result); case "bool_more_equal": result = Name + ":\n"; result += four("bme", "val1", "val2", "N"); result += four("put", "N", "BSSP", "N1"); return(result); case "bool_or": result = Name + ":\n"; result += four("bo", "val1", "val2", "N"); result += four("put", "N", "BSSP", "N1"); return(result); case "bool_and": result = Name + ":\n"; result += four("ba", "val1", "val2", "N"); result += four("put", "N", "BSSP", "N1"); return(result); case "push_id": result = Name + ":\n"; result += "id <- SOM\n"; result += "BSSP <- lit\n"; return(result); } return(""); }
public void OnDeserializeDelta(NetworkReader reader) { // This list can now only be modified by synchronization IsReadOnly = true; int changesCount = (int)reader.ReadPackedUInt32(); for (int i = 0; i < changesCount; i++) { Operation operation = (Operation)reader.ReadByte(); // apply the operation only if it is a new change // that we have not applied yet bool apply = changesAhead == 0; int index = 0; T oldItem = default; T newItem = default; switch (operation) { case Operation.OP_ADD: newItem = DeserializeItem(reader); if (apply) { index = objects.Count; objects.Add(newItem); } break; case Operation.OP_CLEAR: if (apply) { objects.Clear(); } break; case Operation.OP_INSERT: index = (int)reader.ReadPackedUInt32(); newItem = DeserializeItem(reader); if (apply) { objects.Insert(index, newItem); } break; case Operation.OP_REMOVEAT: index = (int)reader.ReadPackedUInt32(); if (apply) { oldItem = objects[index]; objects.RemoveAt(index); } break; case Operation.OP_SET: index = (int)reader.ReadPackedUInt32(); newItem = DeserializeItem(reader); if (apply) { oldItem = objects[index]; objects[index] = newItem; } break; } if (apply) { Callback?.Invoke(operation, index, oldItem, newItem); } // we just skipped this change else { changesAhead--; } } }
void IList <T> .RemoveAt(int index) => source.RemoveAt(index);
public void RemoveTodo(int index) { todos.RemoveAt(index); repository.Delete(index); UpdateProgress(); }
/// <inheritdoc/> public virtual void Remove(int index) { _list.RemoveAt(index); }
virtual public void Pop() { resourcesStack.RemoveAt(resourcesStack.Count - 1); }
public void RemoveAt(int index) { _statements.RemoveAt(index); }
/// <summary> /// Strips shader variants from the underwater shader based on what features are enabled on the ocean material. /// </summary> public void ProcessUnderwaterShader(Shader shader, IList <ShaderCompilerData> data) { // This should not happen. There should always be at least one variant. if (data.Count == 0) { return; } #if CREST_DEBUG var shaderVariantCount = data.Count; var shaderVarientStrippedCount = 0; #endif // Collect all shader keywords. var unusedShaderKeywords = new HashSet <ShaderKeyword>(); for (int i = 0; i < data.Count; i++) { // Each ShaderCompilerData is a variant which is a combination of keywords. Since each list will be // different, simply getting a list of all keywords is not possible. This also appears to be the only // way to get a list of keywords without trying to extract them from shader property names. Lastly, // shader_feature will be returned only if they are enabled. unusedShaderKeywords.UnionWith(data[i].shaderKeywordSet.GetShaderKeywords()); } // Get used shader keywords so we can exclude them. var usedShaderKeywords = new List <ShaderKeyword>(); foreach (var shaderKeyword in unusedShaderKeywords) { // Do not handle built-in shader keywords. if (ShaderKeyword.GetKeywordType(shader, shaderKeyword) != ShaderKeywordType.UserDefined) { usedShaderKeywords.Add(shaderKeyword); continue; } // GetKeywordName will work for both global and local keywords. var shaderKeywordName = ShaderKeyword.GetKeywordName(shader, shaderKeyword); // These keywords will not be on ocean material. if (shaderKeywordName.Contains("_MENISCUS") || shaderKeywordName.Contains("_FULL_SCREEN_EFFECT")) { usedShaderKeywords.Add(shaderKeyword); continue; } // TODO: Strip this once post-processing is more unified. if (shaderKeywordName.Contains("_DEBUG_VIEW_OCEAN_MASK")) { usedShaderKeywords.Add(shaderKeyword); continue; } foreach (var oceanMaterial in _oceanMaterials) { if (oceanMaterial.IsKeywordEnabled(shaderKeywordName)) { usedShaderKeywords.Add(shaderKeyword); break; } } } // Exclude used keywords to obtain list of unused keywords. unusedShaderKeywords.ExceptWith(usedShaderKeywords); for (int index = 0; index < data.Count; index++) { foreach (var unusedShaderKeyword in unusedShaderKeywords) { // IsEnabled means this variant uses this keyword and we can strip it. if (data[index].shaderKeywordSet.IsEnabled(unusedShaderKeyword)) { data.RemoveAt(index--); #if CREST_DEBUG shaderVarientStrippedCount++; #endif break; } } } #if CREST_DEBUG this.shaderVarientStrippedCount += shaderVarientStrippedCount; Debug.Log($"Crest: {shaderVarientStrippedCount} shader variants stripped of {shaderVariantCount} from {shader.name}."); #endif }
static void BadCode(IList <string> lst) => lst.RemoveAt(3);
public void RemoveAt(int index) { Nodes.RemoveAt(index); }