protected string Encode(string value) { UTF8Encoding encoding = new UTF8Encoding(); switch (_DataType.Encoding) { case "BASE64": return Convert.ToBase64String(encoding.GetBytes(value)); case "7BIT": case "8BIT": value = Regex.Replace(value, @"[^\r]\n", "\r\n"); value = Regex.Replace(value, @"\r[^\n]", "\r\n"); bool is7Bit = _DataType.Encoding.Equals("7BIT"); List<byte> data = new List<byte>(encoding.GetBytes(value)); for (int i = data.Count - 1; i >= 0; i--) { if (data[i] == 0) data.RemoveAt(i); if (is7Bit && data[i] > 127) data.RemoveAt(i); } return encoding.GetString(data.ToArray()); default: return value; } }
/// <summary> /// 创建一颗二叉树 /// </summary> /// <param name="list"></param> /// <param name="root"></param> /// <returns></returns> public static TreeNode CreatBinaryTree(List<int> list, TreeNode root) { if (list.Count > 0) { root.left = new TreeNode(list[0]); list.RemoveAt(0); } else { return root; } if (list.Count > 0) { root.right = new TreeNode(list[0]); list.RemoveAt(0); } else { return root; } CreatBinaryTree(list, root.left); return root; }
// case 1: StateMachine -> Default expression of StateMachine's variable -> ... // case 2: StateMachine -> InternalState -> ... public void ReplaceParentChainWithSource(Activity parentActivity, List<object> parentChain) { Activity lastActivity = parentChain[parentChain.Count - 1] as Activity; StateMachine stateMachine = (StateMachine)parentActivity; foreach (Variable variable in stateMachine.Variables) { if (variable != null && variable.Default == lastActivity) { parentChain.Add(stateMachine); return; } } if (parentChain.Count > 1) { // assume lastActivity is InternalState // remove InternalState parentChain.RemoveAt(parentChain.Count - 1); Activity targetActivity = (Activity)parentChain[parentChain.Count - 1]; // the targetActivity will be available in the path parentChain.RemoveAt(parentChain.Count - 1); List<object> path = FindRelativePath(stateMachine, targetActivity); foreach (object pathObject in path) { parentChain.Add(pathObject); } } }
private void Callback(object obj) { if (sideVar >= 0) { ResetFilter (); List<GVar> _vars = new List<GVar>(); if (sideVarLocation == VariableLocation.Global) { _vars = vars; } else { _vars = KickStarter.localVariables.localVars; } GVar tempVar = _vars[sideVar]; switch (obj.ToString ()) { case "Insert after": Undo.RecordObject (this, "Insert variable"); _vars.Insert (sideVar+1, new GVar (GetIDArray (_vars))); DeactivateAllVars (); break; case "Delete": Undo.RecordObject (this, "Delete variable"); _vars.RemoveAt (sideVar); DeactivateAllVars (); break; case "Move up": Undo.RecordObject (this, "Move variable up"); _vars.RemoveAt (sideVar); _vars.Insert (sideVar-1, tempVar); break; case "Move down": Undo.RecordObject (this, "Move variable down"); _vars.RemoveAt (sideVar); _vars.Insert (sideVar+1, tempVar); break; } } sideVar = -1; if (sideVarLocation == AC.VariableLocation.Global) { EditorUtility.SetDirty (this); AssetDatabase.SaveAssets (); } else { if (KickStarter.localVariables) { EditorUtility.SetDirty (KickStarter.localVariables); } } }
static List<int> MakeMegre(List<int> left, List<int> right) { List<int> result = new List<int>(); while (left.Count > 0 || right.Count > 0) { if (left.Count > 0 && right.Count > 0) { if (left[0] <= right[0]) { result.Add(left[0]); left.RemoveAt(0); } else { result.Add(right[0]); right.RemoveAt(0); } } else if (left.Count > 0) { result.Add(left[0]); left.RemoveAt(0); } else if (right.Count > 0) { result.Add(right[0]); right.RemoveAt(0); } return result; } }
public Template CreateTemplate() { List<Cylinder> listCylinders = new List<Cylinder>(); foreach (var middleMinutia in _minutiaeList) { int count = GetCountMinutia(middleMinutia); if (count >= MinNumberMinutiae) { Cylinder[] cylinders = CreateCylinders(middleMinutia); listCylinders.Add(cylinders[0]); listCylinders.Add(cylinders[1]); } } uint maxCount = GetMaxCount(listCylinders); for (int i = 1; i < listCylinders.Count; i += 2) { if (CylinderHelper.GetOneBitsCount(listCylinders[i].Values) >= 0.75 * maxCount) { continue; } listCylinders.RemoveAt(i--); listCylinders.RemoveAt(i--); } return new Template(listCylinders.ToArray()); }
void Start() { float cos = Mathf.Cos(maxAngle); MeshFilter MF = GetComponent<MeshFilter>(); MeshCollider MC = GetComponent<MeshCollider>(); if (MF == null || MC == null || MF.sharedMesh == null) { Debug.LogError("PlatformCollision needs a MeshFilter and a MeshCollider"); return; } Mesh M = new Mesh(); Vector3[] verts = MF.sharedMesh.vertices; List<int> triangles = new List<int>(MF.sharedMesh.triangles); for (int i = triangles.Count - 1; i >= 0; i -= 3) { Vector3 P1 = transform.TransformPoint(verts[triangles[i - 2]]); Vector3 P2 = transform.TransformPoint(verts[triangles[i - 1]]); Vector3 P3 = transform.TransformPoint(verts[triangles[i]]); Vector3 faceNormal = Vector3.Cross(P3 - P2, P1 - P2).normalized; if (Vector3.Dot(faceNormal, Vector3.up) <= cos) { triangles.RemoveAt(i); triangles.RemoveAt(i - 1); triangles.RemoveAt(i - 2); } } M.vertices = verts; M.triangles = triangles.ToArray(); MC.sharedMesh = M; }
public override void Read(List<byte> byteCode) { byteCode.RemoveAt(byteCode.Count - 1); byteCode.RemoveAt(byteCode.Count - 1); byteCode.RemoveAt(byteCode.Count - 1); byteCode.RemoveAt(byteCode.Count - 1); }
public static List<string> Merge(List<string> left, List<string> right) { List<string> result = new List<string>(); while (left.Count > 0 || right.Count > 0) { if (left.Count > 0 && right.Count > 0) { if (string.Compare(left[0], right[0]) < 0) { result.Add(left[0]); left.RemoveAt(0); } else { result.Add(right[0]); right.RemoveAt(0); } } else if (left.Count > 0) { result.Add(left[0]); left.RemoveAt(0); } else if (right.Count > 0) { result.Add(right[0]); right.RemoveAt(0); } } return result; }
static void Main(string[] args) { string[] sequence = Console.ReadLine().Split(); int kN = int.Parse(Console.ReadLine()); int count = 1; List<int> seq = new List<int>(); foreach (var item in sequence) { seq.Add(int.Parse(item)); } int num = seq[0]; for (int i = 1; i < seq.Count; i++) { if (num==seq[i]) { count++; if (count==kN) { seq.RemoveAt(i); seq.RemoveAt(i - 1); count = 1; } } } }
protected override void DefaultRemoveTargetsFilter(List<WoWObject> units) { for (int i = units.Count - 1; i >= 0; i--) { if (!units[i].IsValid) { units.RemoveAt(i); continue; } WoWUnit u = units[i].ToUnit(); if (u.IsFriendly || u.Dead || u.IsPet() || !u.Combat || IsCrowdControlled(u)) { units.RemoveAt(i); continue; } if (u.CurrentTarget != null) { WoWUnit tar = u.CurrentTarget; if (tar.IsPlayer && tar.IsHostile) { units.RemoveAt(i); continue; } } } }
private static void SecondTask(string[] cakes, int friends) { List<int> cakesSize = new List<int>(); for (int i = 0; i < cakes.Length; i++) { cakesSize.Add(int.Parse(cakes[i])); } cakesSize.Sort(); int bites = 0; while (cakesSize.Count != 0) { bites += cakesSize[cakesSize.Count - 1]; cakesSize.RemoveAt(cakesSize.Count - 1); for (int i = 0; i < friends; i++) { if (cakesSize.Count == 0) { break; } cakesSize.RemoveAt(cakesSize.Count - 1); } } Console.WriteLine(bites); }
protected string FindArticle(List<string> w, List<string> t) { for (int i = 0; i < t.Count; ++i) { if ((t[i] == Tagger.Tags.Noun) || (t[i] == Tagger.Tags.NounPlural)) { if ((i > 0) && (t[i - 1] == Tagger.Tags.Determiner)) { t.RemoveAt(i - 1); w.RemoveAt(i - 1); --i; } string s = w[i]; t.RemoveAt(i); w.RemoveAt(i); while ((i < t.Count) && ((t[i] == Tagger.Tags.Noun) || (t[i] == Tagger.Tags.NounPlural))) { s += " " + w[i]; t.RemoveAt(i); w.RemoveAt(i); } return s; } } return string.Empty; }
public static List<int> merge(List<int> left, List<int> right) { List<int> result = new List<int>(); while (left.Count > 0 && right.Count > 0) { if (left[0] < right[0]) { result.Add(left[0]); left.RemoveAt(0); } else { result.Add(right[0]); right.RemoveAt(0); } } while (left.Count > 0) { result.Add(left[0]); left.RemoveAt(0); } while (right.Count > 0) { result.Add(right[0]); right.RemoveAt(0); } return result; }
//Removes all irc server related text public static string Filter(string buf) { int i = 0, j = 0; List<char> charList = new List<char>(); charList.AddRange(buf.ToCharArray()); charList.RemoveAt(0); do { if (charList[i].Equals(':') & (j < 1)) { break; } else { charList.RemoveAt(0); } } while (i < charList.Count); char[] text = charList.ToArray(); buf = new string(text); charList = null; text = null; return buf; }
public static TileMapLayer Parse(List<string> rows) { var layer = new TileMapLayer (); while (rows.Count > 0 && rows [0].IndexOf ("}") == -1) { if (rows [0].IndexOf ("{") == -1) { var propName = rows [0].Substring (0, rows [0].IndexOf (":")).Trim (); var prop = ""; foreach (var part in propName.Split("_".ToCharArray())) { prop += part.Substring (0, 1).ToUpper () + part.Substring (1); } var value = rows [0].Substring (rows [0].IndexOf (":") + 1).Replace("\"",""); var property = layer.GetType ().GetProperty (prop); property.SetValue(layer, Convert.ChangeType(value, property.PropertyType)); } else { var propName = rows [0].Substring (0, rows [0].IndexOf ("{")).Trim (); switch (propName) { case "cell": var cell = TileMapCell.Parse (rows); layer.Cells.Add (cell); break; } } rows.RemoveAt (0); } rows.RemoveAt (0); return layer; }
public static List<GeoXYPoint> CoverageDistributePoint(GeoPolygon polygonPeak, double r) { List<GeoXYPoint> list = new List<GeoXYPoint>(); GeoXYPoint centerPoint = new GeoXYPoint((polygonPeak.Right + polygonPeak.Left) / 2.0, (polygonPeak.Top + polygonPeak.Bottom) / 2.0); GeoXYPoint southwest = GetSouthWestPoint(polygonPeak.Left, polygonPeak.Right, polygonPeak.Top, polygonPeak.Bottom, centerPoint, r); GeoXYPoint northeast = GetNorthEastClutterPoint(polygonPeak.Left, polygonPeak.Right, polygonPeak.Top, polygonPeak.Bottom, centerPoint, r); list = InitialDistribute(southwest, northeast, r); int index = 0; while (index < list.Count) { if (!polygonPeak.IsPointInPolygon(list[index])) { list.RemoveAt(index); index--; } index++; } for (int i = 0; list.Count == 0; i++) { if (i >= polygonPeak.Points.Count) { return list; } list = InitialDistribute(polygonPeak.Points[i], northeast, r); for (index = 0; index < list.Count; index++) { if (!polygonPeak.IsPointInPolygon(list[index])) { list.RemoveAt(index); index--; } } } return list; }
private void replaceTokensWithResult(List<MathToken> tokens, int indexOfOperator, int result) { tokens[indexOfOperator - 1] = new MathNumber(result.ToString()); tokens.RemoveAt(indexOfOperator); tokens.RemoveAt(indexOfOperator); }
/// <summary> /// Removes any "." and ".." entries in the path. /// </summary> /// <param name="input"></param> /// <returns>The input filename with no parent or current directory references.</returns> public static string MakeCanonicalFileName(string input) { string drive = input.StartsWith(@"\\") ? @"\\" :System.IO.Path.GetPathRoot(input); string dirstring = drive == null ? input : input.Remove(0, drive.Length); string[] dirs = dirstring.Split(new char[] { System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar }); List<string> dirList = new List<string>(dirs); for (int index = 0; index < dirList.Count; ) { if (dirList[index] == "." || dirList[index] == "") { dirList.RemoveAt(index); } else if (dirList[index] == ".." && index > 0) { dirList.RemoveAt(index); dirList.RemoveAt(index - 1); --index; } else { ++index; } } return drive + String.Join(System.IO.Path.DirectorySeparatorChar.ToString(), dirList.ToArray()); }
public void Execute(List<string> arguments) { if (arguments.Count == 0) { ShowNoArgsMessage(); } else { while (arguments.Count != 0) { string key; string value; key = arguments[0]; arguments.RemoveAt(0); if (arguments.ElementAtOrDefault(0) != null) { value = arguments[0]; arguments.RemoveAt(0); } else { value = "<null>"; } Console.WriteLine("{0} - {1}", key, value); } } }
/// <summary> /// Formats the given parameters to call a function. /// </summary> /// <param name="parameters">An array of parameters.</param> /// <returns>The mnemonics to pass the parameters.</returns> public string FormatParameters(IntPtr[] parameters) { // Declare a var to store the mnemonics var ret = new StringBuilder(); var paramList = new List<IntPtr>(parameters); // Store the first parameter in the ECX register if (paramList.Count > 0) { ret.AppendLine("mov ecx, " + paramList[0]); paramList.RemoveAt(0); } // Store the second parameter in the EDX register if (paramList.Count > 0) { ret.AppendLine("mov edx, " + paramList[0]); paramList.RemoveAt(0); } // For each parameters (in reverse order) paramList.Reverse(); foreach (var parameter in paramList) { ret.AppendLine("push " + parameter); } // Return the mnemonics return ret.ToString(); }
private static void ReorderWords(List<string> words) { for (int i = 0; i < words.Count; i++) { int position = words[i].Length % (words.Count + 1); words.Insert(position, words[i]); if (i <= position) { words.RemoveAt(i); } else if (i > position) { words.RemoveAt(i + 1); } } int maxLength = 0; foreach (var word in words) { if (word.Length > maxLength) { maxLength = word.Length; } // Console.WriteLine(word); } Print(words, maxLength); }
public Path Cd(string newPath) { if (newPath.Length > 2 && newPath.Substring(0, 2) == "./") { newPath = newPath.Substring(2, newPath.Length - 2); } var paths = new List<string>(); var newPathArray = newPath.Split('/'); foreach (var word in this.CurrentPath.Substring(0, this.CurrentPath.Length)) { paths.Add(word.ToString()); } for (var counter = 0; counter < newPathArray.Length; counter = counter + 1) { if (newPathArray[counter] == "..") { paths.RemoveAt(paths.Count - 2); paths.RemoveAt(paths.Count - 1); } else if(newPathArray[counter].Length > 0) { paths.Add("/"); paths.Add(newPathArray[counter]); } } return new Path(String.Join("", paths.ToArray())); }
static List<int> Merge(List<int> left, List<int> right) { List<int> temp = new List<int>(); while (left.Count > 0 || right.Count > 0) { if (left.Count > 0 && right.Count > 0) { if (left[0] <= right[0]) { temp.Add(left[0]); left.RemoveAt(0); } else { temp.Add(right[0]); right.RemoveAt(0); } } else if (left.Count > 0) { temp.Add(left[0]); left.RemoveAt(0); } else { temp.Add(right[0]); right.RemoveAt(0); } } return temp; }
public static void Write(BinaryWriter writer, DateTime? time) { if (!time.HasValue) { // 1 byte long byte[] nullBytes = { 255 }; writer.Write(nullBytes); return; } // byte is 1 byte long :) const byte size = 5; writer.Write(size); // Format: // 00:00:00 gives 05 00 00 00 00 00 // 00:00:01 gives 05 80 96 98 00 00 -> 00 00 98 96 80 = 1.0000000 // 00:01:00 gives 05 00 46 C3 23 00 -> 00 23 C3 46 00 = 60.0000000 // 01:00:00 gives 05 00 68 C4 61 08 -> 08 61 C4 68 00 = 3600.0000000 DateTime initTime = DateTime.Parse("00:00:00", System.Globalization.CultureInfo.InvariantCulture); TimeSpan span = time.Value - initTime; byte[] valueBytes = BitConverter.GetBytes((long)(span.TotalSeconds * 10000000)); List<byte> bytes = new List<byte>(valueBytes); bytes.RemoveAt(7); bytes.RemoveAt(6); bytes.RemoveAt(5); writer.Write(bytes.ToArray()); }
private static List<int> Merge(List<int> leftList, List<int> rightList) { List<int> result = new List<int>(); while (leftList.Count > 0 || rightList.Count > 0) { if (leftList.Count > 0 && rightList.Count > 0) { if (leftList[0] <= rightList[0]) { result.Add(leftList[0]); leftList.RemoveAt(0); } else { result.Add(rightList[0]); rightList.RemoveAt(0); } } else if (leftList.Count > 0) { result.Add(leftList[0]); leftList.RemoveAt(0); } else if (rightList.Count > 0) { result.Add(rightList[0]); rightList.RemoveAt(0); } } return result; }
static void Main() { int n = int.Parse(Console.ReadLine()); List<string> input = new List<string>(n+1); int longestWord = 0; for (int i = 0; i < n; i++) { input.Add(Console.ReadLine()); if (input[i].Length > longestWord) longestWord = input[i].Length; } int newPos = 0; for (int i = 0; i < n; i++) { newPos = (input[i].Length % (n + 1)); input.Insert(newPos, input[i]); if (newPos < i) input.RemoveAt(i + 1); else input.RemoveAt(i); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < longestWord; i++) for (int j = 0; j < n; j++) if (i < input[j].Length) sb.Append(input[j][i]); Console.WriteLine(sb); }
public static List<Tuple<Vector2, float>> merge(List<Tuple<Vector2, float>> Left, List<Tuple<Vector2, float>> Right) { // keep looping untill 1 list remains List<Tuple<Vector2, float>> result = new List<Tuple<Vector2, float>>(); while (Left.Count > 0 && Right.Count > 0) { if (Left[0].Item2 < Right[0].Item2) { result.Add(Left[0]); Left.RemoveAt(0); } else { result.Add(Right[0]); Right.RemoveAt(0); } } while (Left.Count > 0) { result.Add(Left[0]); Left.RemoveAt(0); } while (Right.Count > 0) { result.Add(Right[0]); Right.RemoveAt(0); } return result; }
private static List<Movement> FindPath(int r, int c, int dr, int dc, List<Movement> path, bool[,] blocks) { if (r == dr && c == dc) return path; blocks [r, c] = true; if (CanMove (r, c, Movement.DOWN, blocks)) { path.Add (Movement.DOWN); List<Movement> finalPath = FindPath (r + 1, c, dr, dc, path, blocks); if (finalPath != null) return finalPath; else path.RemoveAt (path.Count - 1); } if (CanMove (r, c, Movement.RIGHT, blocks)) { path.Add (Movement.RIGHT); List<Movement> finalPath = FindPath (r, c + 1, dr, dc, path, blocks); if (finalPath != null) return finalPath; else path.RemoveAt (path.Count - 1); } return null; }
public static List<string> CleanupList(List<string> l, bool cleanDupes) { // clone list first l = new List<string>(l); for (int x = 0; x < l.Count; x++) { l[x] = l[x].Trim(); if (l[x].Length == 0) { l.RemoveAt(x--); } else if (cleanDupes) { for (int y = 0; y < x; y++) { if (l[y].Equals(l[x])) { l.RemoveAt(x--); break; } } } } l.TrimExcess(); return l; }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <inheritdoc /> /// <summary> /// Removes the first occurrence of a specific object from the /// <see cref="T:System.Collections.Generic.ICollection`1" />. /// </summary> /// <exception cref="T:System.NotSupportedException"> The /// <see cref="T:System.Collections.Generic.ICollection`1" /> /// is read-only. </exception> /// <param name="item"> The object to remove from the /// <see cref="T:System.Collections.Generic.ICollection`1" />. </param> /// <returns> /// <see langword="true" /> if <paramref name="item" /> was successfully removed from the /// <see cref="T:System.Collections.Generic.ICollection`1" />; otherwise, /// <see langword="false" />. This method also returns <see langword="false" /> if /// <paramref name="item" /> is not found in the original /// <see cref="T:System.Collections.Generic.ICollection`1" />. /// </returns> /// <seealso cref="M:System.Collections.Generic.ICollection{T}.Remove(T)" /> public bool Remove(T item) { int index = IndexOf(item); if (index >= 0) { m_innerList?.RemoveAt(index); return(true); } return(false); }
private void removeIgredient() { if (igredientList.Count > 0) { igredientList?.RemoveAt(igredientList.Count - 1); OnPropertyChanged("IgredientListString"); } }
void Undo(System.Object sender, System.EventArgs e) { if (completedPaths.Count == 0) { return; } completedPaths?.RemoveAt(completedPaths.Count - 1); canvasView.InvalidateSurface(); }
public void TruncateLastFreePageMarker() { if (_header.ReleasedPageCount == 0) { throw new InvalidOperationException("There are no free pages in pagemap"); } _freePageIndexes?.RemoveAt(_freePageIndexes.Count - 1); _header.ReleasedPageCount--; }
private void RemoveFromList() { if ((_index >= 0) & (_index < _instruments.Count)) { _instruments?.RemoveAt(_index); _index = INVALID_INDEX; OnListChanged(); } }
public void RemoveAt(int index) { if (index == 0) { first = null; if (rest?.Count > 0) { first = rest [0]; rest.RemoveAt(0); } return; } index -= 1; rest?.RemoveAt(index); }
private void WriteSchemaInternal(JSchema schema) { _schemaStack?.Add(schema); if (schema.Valid != null) { _writer.WriteValue(schema.Valid); } else { WriteSchemaObjectInternal(schema); } _schemaStack?.RemoveAt(_schemaStack.Count - 1); }
private static void UsunZadanie() { ListaZadan(); try { int nrPozycji = int.Parse(OdbierzDane("Podaj nr. pozycji do usunięcia")); List <Zadanie> lzadan = organizer.ListaZadan() as List <Zadanie>; lzadan?.RemoveAt(nrPozycji - 1); } catch (Exception ex) { Console.WriteLine($"Błędne dane!\n{ex.Message}"); } }
public void SumEvaluation(List <int> vectorList, List <int> sublist) { var internalVectorList = new List <int>(); internalVectorList.AddRange(vectorList); foreach (var currentValue in sublist) { internalVectorList?.RemoveAt(0); var internalSubList = new List <int>(); internalVectorList.ForEach(x => internalSubList.Add(x + currentValue)); sumTotal.AddRange(internalSubList); if (internalVectorList.Count > 0) { SumEvaluation(internalVectorList, internalSubList); } } }
private bool IsRequestValid(ref HTTPJsonRequestInfo info, ref List <HTTPJsonRequestInfo> list) { bool allowSend = true; switch (info.requestType) { case HttpRequestType.Post: allowSend = info.data != default; if (!allowSend) { Debug.LogError("使用Http的Post方式(JSON)请求服务器,表单数据不能为空!URL: ".Append(info.requestURL)); list?.RemoveAt(0); } else { } break; } return(allowSend); }
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { if (subtitleListView1.SelectedItems.Count < 1) { return; } var idx = subtitleListView1.SelectedItems[0].Index; _bluRaySubtitles?.RemoveAt(idx); _extra.RemoveAt(idx); _subtitle.Paragraphs.RemoveAt(idx); _subtitle.Renumber(); subtitleListView1.Fill(_subtitle); if (idx >= _subtitle.Paragraphs.Count) { idx++; } if (idx >= 0) { subtitleListView1.SelectIndexAndEnsureVisible(_subtitle.GetParagraphOrDefault(idx)); } }
private void listView1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue != 46) { return; } if (listView1.SelectedItems[0].Text == null) { return; } foreach (var unused in listView1.SelectedItems) { var loc = listView1.SelectedItems[0].Index; if (Files != null) { File.Delete(Files[loc]); } listView1.Items.RemoveAt(loc); Files?.RemoveAt(loc); } }
// Roughness pass. Remove shards from cluster and add to another. static void RoughnessPassShards(List <RFCluster> clusters) { // Set clusters neib info RFCluster.SetClusterNeib(clusters, true); // Check cluster for shard with one neib among cluster shards for (int s = clusters.Count - 1; s >= 0; s--) { RFCluster cluster = clusters[s]; // Skip clusters with 2 shards if (cluster.shards.Count == 2) { continue; } // Skip clusters without neib clusters if (cluster.neibClusters.Count == 0) { continue; } // Collect shards to exclude from cluster List <RFShard> excludeShards = new List <RFShard>(); List <RFCluster> attachToClusters = new List <RFCluster>(); // Check all shards and compare area with own cluster and neib clusters foreach (RFShard shard in cluster.shards) { // Get amount of neibs among cluster shards float areaInCluster = 0f; for (int i = 0; i < shard.neibShards.Count; i++) { if (cluster.shards.Contains(shard.neibShards[i]) == true) { areaInCluster += shard.nArea[i]; } } // Compare with amount of shards from neib clusters List <float> neibAreaList = new List <float>(); foreach (RFCluster neibCluster in cluster.neibClusters) { float areaInNeibCluster = 0f; for (int i = 0; i < shard.neibShards.Count; i++) { if (neibCluster.shards.Contains(shard.neibShards[i]) == true) { areaInNeibCluster += shard.nArea[i]; } } neibAreaList.Add(areaInNeibCluster); } // Get maximum neibs in neib cluster float maxArea = neibAreaList.Max(); // Skip shard because neib clusters has less neib shards if (areaInCluster >= maxArea) { continue; } // Collect cluster which has more neibs for shard than own cluster for (int i = 0; i < neibAreaList.Count; i++) { if (maxArea == neibAreaList[i]) { excludeShards.Add(shard); attachToClusters.Add(cluster.neibClusters[i]); } } } // Reorder shards if (excludeShards.Count > 0) { for (int i = 0; i < excludeShards.Count; i++) { // Exclude from own cluster for (int c = cluster.shards.Count - 1; c >= 0; c--) { if (cluster.shards[c] == excludeShards[i]) { cluster.shards.RemoveAt(c); } } // Add to neib cluster attachToClusters[i].shards.Add(excludeShards[i]); } } } // Remove empty and solo clusters for (int i = clusters.Count - 1; i >= 0; i--) { // Remove solo shard if (clusters[i].shards.Count == 1) { clusters[i].shards.Clear(); } // Remove empty cluster if (clusters[i].shards.Count == 0) { clusters.RemoveAt(i); } } }
public void Dispose() { objectList?.RemoveAt(objectList.Count - 1); }
private void ImageGV_ItemClick(object sender, ItemClickEventArgs e) { m_files.RemoveAt(m_images.IndexOf((Image)e.ClickedItem)); m_images.Remove((Image)e.ClickedItem); }
private void CreateDymmyData(NHeatMapSeries heatMap) { Random rand = new Random(); List <NHeatZone> heatZones = new List <NHeatZone>(); double maxTemperature = 70; while (heatZones.Count < 50) { int x = 0; int y = 0; switch (rand.Next(4)) { case 0: // left x = -(int)maxTemperature / 2 + 1; y = rand.Next(m_SizeY); break; case 1: // top x = rand.Next(m_SizeX); y = -(int)maxTemperature / 2 + 1; break; case 2: // right x = m_SizeX - (int)maxTemperature / 2 - 1; y = rand.Next(m_SizeY); break; case 3: // bottom x = rand.Next(m_SizeX); y = +(int)maxTemperature / 2 - 1; break; } // if no more heat zones -> create new ones NHeatZone heatZone = new NHeatZone(x, y, maxTemperature); do { heatZone.m_DX = rand.Next(4) - 2; heatZone.m_DY = rand.Next(4) - 2; }while (heatZone.m_DX == 0 && heatZone.m_DY == 0); heatZones.Add(heatZone); } // gets the values heatMap.Data.SetValues(double.NaN); double[] values = heatMap.Data.Values; for (int i = heatZones.Count - 1; i >= 0; i--) { NHeatZone heatZone = heatZones[i]; int radius = heatZone.m_Radius; // move the heat zone heatZone.m_X += heatZone.m_DX; heatZone.m_Y += heatZone.m_DY; bool removeZone = false; if (heatZone.m_X < -radius) { removeZone = true; } else if (heatZone.m_X >= m_SizeX + radius) { removeZone = true; } if (heatZone.m_Y < -radius) { removeZone = true; } else if (heatZone.m_Y >= m_SizeX + radius) { removeZone = true; } if (removeZone) { heatZones.RemoveAt(i); } else { int centerX = heatZone.m_X; int centerY = heatZone.m_Y; int startX = Math.Max(0, centerX - radius); int startY = Math.Max(0, centerY - radius); int endX = Math.Min(m_SizeX - 1, centerX + radius); int endY = Math.Min(m_SizeY - 1, centerY + radius); for (int x = startX; x <= endX; x++) { for (int y = startY; y <= endY; y++) { double value = heatZone.m_Temperature - 2 * Math.Sqrt(Math.Pow(x - centerX, 2) + Math.Pow(y - centerY, 2)); if (value >= 0) { int index = y * m_SizeX + x; double curValue = values[index]; if (double.IsNaN(curValue)) { values[index] = value; } else { curValue += value; if (curValue > maxTemperature) { curValue = maxTemperature; } values[index] = curValue; } } } } } } heatMap.Data.OnDataChanged(); }
public void RemoveMarkMap(int position) { _markingList?.RemoveAt(position); }
public static void removeAt<T>( ref T[] _array, int _index ) { List<T> list = new List<T>(_array); list.RemoveAt(_index); _array = list.ToArray(); }
public void RemoveAt(int index) { m_List?.RemoveAt(index); SetDirty(); }
public void deleteStudent(Student student) { students?.RemoveAt(student.getRollNo()); Console.WriteLine($"Student: Roll No {student.getRollNo()}, deleted from database"); }
public void RemoveCustomFolderAt(int index) { customFolders?.RemoveAt(index); }
public void RemoveRowDataItemAt(int index) { rowDataItems?.RemoveAt(index); }
private void WriteSchemaInternal(JSchema schema) { _schemaStack?.Add(schema); _writer.WriteStartObject(); if (schema == _rootSchema) { WritePropertyIfNotNull(_writer, Constants.PropertyNames.Schema, schema.SchemaVersion); } WritePropertyIfNotNull(_writer, Constants.PropertyNames.Id, schema.Id); WritePropertyIfNotNull(_writer, Constants.PropertyNames.Title, schema.Title); WritePropertyIfNotNull(_writer, Constants.PropertyNames.Description, schema.Description); if (schema._extensionData != null) { foreach (KeyValuePair <string, JToken> extensionDataPair in schema._extensionData) { _writer.WritePropertyName(extensionDataPair.Key); WriteToken(schema, _writer, extensionDataPair.Value); } } if (schema.Type != null) { WriteType(Constants.PropertyNames.Type, _writer, schema.Type.Value); } if (schema.Default != null) { _writer.WritePropertyName(Constants.PropertyNames.Default); schema.Default.WriteTo(_writer); } if (!schema.AllowAdditionalProperties) { _writer.WritePropertyName(Constants.PropertyNames.AdditionalProperties); _writer.WriteValue(schema.AllowAdditionalProperties); } else { if (schema.AdditionalProperties != null) { ReferenceOrWriteSchema(schema, schema.AdditionalProperties, Constants.PropertyNames.AdditionalProperties); } } if (!schema.AllowAdditionalItems) { _writer.WritePropertyName(Constants.PropertyNames.AdditionalItems); _writer.WriteValue(schema.AllowAdditionalItems); } else { if (schema.AdditionalItems != null) { ReferenceOrWriteSchema(schema, schema.AdditionalItems, Constants.PropertyNames.AdditionalItems); } } WriteSchemaDictionaryIfNotNull(schema, _writer, Constants.PropertyNames.Properties, schema._properties); WriteRequired(schema); WriteSchemaDictionaryIfNotNull(schema, _writer, Constants.PropertyNames.PatternProperties, schema._patternProperties); WriteItems(schema); WritePropertyIfNotDefault(_writer, Constants.PropertyNames.UniqueItems, schema.UniqueItems); WritePropertyIfNotNull(_writer, Constants.PropertyNames.Minimum, schema.Minimum); WritePropertyIfNotNull(_writer, Constants.PropertyNames.Maximum, schema.Maximum); WritePropertyIfNotDefault(_writer, Constants.PropertyNames.ExclusiveMinimum, schema.ExclusiveMinimum); WritePropertyIfNotDefault(_writer, Constants.PropertyNames.ExclusiveMaximum, schema.ExclusiveMaximum); WritePropertyIfNotNull(_writer, Constants.PropertyNames.MinimumLength, schema.MinimumLength); WritePropertyIfNotNull(_writer, Constants.PropertyNames.MaximumLength, schema.MaximumLength); WritePropertyIfNotNull(_writer, Constants.PropertyNames.MinimumItems, schema.MinimumItems); WritePropertyIfNotNull(_writer, Constants.PropertyNames.MaximumItems, schema.MaximumItems); WritePropertyIfNotNull(_writer, Constants.PropertyNames.MinimumProperties, schema.MinimumProperties); WritePropertyIfNotNull(_writer, Constants.PropertyNames.MaximumProperties, schema.MaximumProperties); WritePropertyIfNotNull(_writer, Constants.PropertyNames.MultipleOf, schema.MultipleOf); WritePropertyIfNotNull(_writer, Constants.PropertyNames.Pattern, schema.Pattern); WritePropertyIfNotNull(_writer, Constants.PropertyNames.Format, schema.Format); if (!schema._enum.IsNullOrEmpty()) { _writer.WritePropertyName(Constants.PropertyNames.Enum); _writer.WriteStartArray(); foreach (JToken token in schema._enum) { token.WriteTo(_writer); } _writer.WriteEndArray(); } WriteSchemas(schema, schema._allOf, Constants.PropertyNames.AllOf); WriteSchemas(schema, schema._anyOf, Constants.PropertyNames.AnyOf); WriteSchemas(schema, schema._oneOf, Constants.PropertyNames.OneOf); WriteSchema(schema, schema.Not, Constants.PropertyNames.Not); _writer.WriteEndObject(); _schemaStack?.RemoveAt(_schemaStack.Count - 1); }
public void RemoveAt(int index) { _list?.RemoveAt(index); }
// Check cluster for connectivity and create new connected clusters void ConnectivityCheck(List <RFCluster> childClusters) { // New list for solo shards List <RFShard> soloShards = new List <RFShard>(); List <RFCluster> newChildClusters = new List <RFCluster>(); // Check every cluster for connectivity foreach (RFCluster childCluster in childClusters) { // Collect solo shards with no neibs for (int i = childCluster.shards.Count - 1; i >= 0; i--) { if (childCluster.shards[i].neibShards.Count == 0) { soloShards.Add(childCluster.shards[i]); } } // Get list of all shards to check List <RFShard> allShardsLoc = new List <RFShard>(); foreach (RFShard shard in childCluster.shards) { allShardsLoc.Add(shard); } // Check all shards and collect new clusters int shardsAmount = allShardsLoc.Count; List <RFCluster> newClusters = new List <RFCluster>(); while (allShardsLoc.Count > 0) { // List of connected shards List <RFShard> newClusterShards = new List <RFShard>(); // List of check shards List <RFShard> checkShards = new List <RFShard>(); // Start from first shard checkShards.Add(allShardsLoc[0]); newClusterShards.Add(allShardsLoc[0]); // Collect by neibs while (checkShards.Count > 0) { // Add neibs to check foreach (RFShard neibShard in checkShards[0].neibShards) { // If neib among current cluster shards if (allShardsLoc.Contains(neibShard) == true) { // And not already collected if (newClusterShards.Contains(neibShard) == false) { checkShards.Add(neibShard); newClusterShards.Add(neibShard); } } } // Remove checked checkShards.RemoveAt(0); } // Child cluster connected if (shardsAmount == newClusterShards.Count) { allShardsLoc.Clear(); } // Child cluster not connected else { // Create new cluster and add to parent RFCluster newCluster = new RFCluster(); newCluster.pos = childCluster.pos; newCluster.depth = childCluster.depth; newCluster.shards = newClusterShards; // Set id clusterId++; newCluster.id = clusterId; newClusters.Add(newCluster); // Remove from all shards list for (int i = allShardsLoc.Count - 1; i >= 0; i--) { if (newClusterShards.Contains(allShardsLoc[i]) == true) { allShardsLoc.RemoveAt(i); } } } } // Non connectivity. Remove original cluster if (newClusters.Count > 0) { childCluster.shards.Clear(); newChildClusters.AddRange(newClusters); } } // Clear empty clusters for (int i = childClusters.Count - 1; i >= 0; i--) { if (childClusters[i].shards.Count == 0) { childClusters.RemoveAt(i); } } // Collect new clusters childClusters.AddRange(newChildClusters); // Set clusters neib info RFCluster.SetClusterNeib(childClusters, true); // Second pass Find neib cluster for solo shards SetSoloShardToCluster(soloShards, childClusters); // Roughness pass. Remove shards from cluster and add to another. if (smoothPass > 0) { RoughnessPassShards(childClusters); } }
public void RemoveOption( int index ) { if ( index < 0 ) return; optionKeys.RemoveAt( index ); optionVals.RemoveAt( index ); }
public void Delete(int i) { BlogList.RemoveAt(i); }
public TokenProgram[] Tokenize(string sourceText, out string[] names, out string[] expressions) { var symbols = new[] { "if", "else", "return", "decl", ";", "(", ")", "{", "}", ",", "while" }; foreach (var symbol in symbols) { sourceText = sourceText.Replace(symbol, " " + symbol + " "); } AddSpace(ref sourceText, '=', new [] { '!', '=' }, new [] { '=' }); var rawTokens = sourceText.Split(new[] { " ", Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); var tokens = new List <TokenProgram>(); var listNames = new List <string>(); var listExpressions = new List <string>(); var parsingExpression = false; TokenProgram startToken = TokenProgram.Assign; var balance = 0; var startBalance = 0; foreach (var rawToken in rawTokens) { if (TryParse(rawToken, out TokenProgram token)) { if (token == TokenProgram.ROpen) { balance++; } else if (token == TokenProgram.RClose) { balance--; } if (!parsingExpression) { tokens.Add(token); if (token == TokenProgram.Assign || token == TokenProgram.ROpen || token == TokenProgram.Return) { parsingExpression = true; listExpressions.Add(string.Empty); tokens.Add(TokenProgram.Expr); if (token == TokenProgram.Assign) { startToken = TokenProgram.Assign; } else if (token == TokenProgram.Return) { startToken = TokenProgram.Return; } else if (token == TokenProgram.ROpen) { startToken = TokenProgram.ROpen; } startBalance = balance; } } else { if (startToken == TokenProgram.Assign && (token == TokenProgram.Comma || token == TokenProgram.Sem) && balance == startBalance || startToken == TokenProgram.ROpen && token == TokenProgram.RClose && balance == startBalance - 1 || startToken == TokenProgram.Return && token == TokenProgram.Sem && balance == startBalance) { if (listExpressions[listExpressions.Count - 1] == string.Empty) { tokens.RemoveAt(tokens.Count - 1); listExpressions.RemoveAt(listExpressions.Count - 1); } parsingExpression = false; tokens.Add(token); } else if (startToken == TokenProgram.ROpen && token == TokenProgram.Comma) { if (listExpressions[listExpressions.Count - 1] == string.Empty) { tokens.RemoveAt(tokens.Count - 1); listExpressions.RemoveAt(listExpressions.Count - 1); } listExpressions.Add(string.Empty); tokens.Add(TokenProgram.Comma); tokens.Add(TokenProgram.Expr); } else { listExpressions[listExpressions.Count - 1] += rawToken; } } } else if (!parsingExpression) { if (IsName(rawToken)) { tokens.Add(TokenProgram.Name); listNames.Add(rawToken); } else { throw new Exception("invalid data"); } } else { listExpressions[listExpressions.Count - 1] += rawToken; } } names = listNames.ToArray(); expressions = listExpressions.ToArray(); return(tokens.ToArray()); }
void RemoveLastCellFromWay() { way?.RemoveAt(0); }
public void RemovePrice(int position) { _priceList?.RemoveAt(position); }