public int Pop() { if (IsEmpty) { throw new KeyNotFoundException("Heap is empty"); } int value; if (ListA.Count > 0 && ListB.Count > 0) { if (ListA[0] <= ListB[0]) { value = ListA[0]; ListA.RemoveAt(0); } else { value = ListB[0]; ListB.RemoveAt(0); } } else if (ListA.Count > 0) { value = ListA[0]; ListA.RemoveAt(0); } else { value = ListB[0]; ListB.RemoveAt(0); } return(value); }
public void UsingLinqForeach() { ListA.ForEach(itemA => { ListB.ForEach(itemB => { if (itemA.P1 == itemB.P1) { itemA.P2 = itemB.P2; } }); }); }
public Program() { _sendedList = new ListA("sendedList.txt"); _sendedList.Clear(); _list.Add("darkGhost"); //for (int i = 0; i < 5; i++) // new Client().StartSpammAsync(); //for (int i = 0; i < 2; i++) //{ // new Client().StartPopulateAsync(); //} new Client().StartSpamm(); "end".Trace(); }
private static void Main(string[] args) { IMyList a = new ListA { new ClassA { ClassAFoo = "I'm an A" } }; IMyList b = new ListB { new ClassB { ClassBFoo = "I'm a B" } }; a.CommonOperation(); b.CommonOperation(); }
public Program() { _sendedList = new ListA("postedlist.txt"); for (int i = 0; i < 5; i++) new Client().StartSpammAsync(); for (int i = 0; i < 1; i++) new Client().StartPopulateAsync(); while (true) { Thread.Sleep(5000); _sendedList.Flush(); Trace.WriteLine("flushed"); } }
/// <summary> /// performs exactly one iteration of the algorithm /// </summary> public override void DoOneRun() { if (Finished) { throw new GSTException("algorithm is finished"); } var watch = Stopwatch.StartNew(); var listMatches = new List <Tile <T> >(); LastMaximumMatch = MinimumMatchLength; // for every token in A that is unmarked foreach (var tA in ListA.Where(t => !t.Marked)) { var tokA = tA; // CLOSURE int indA = ListA.IndexOf(tokA); // for every token in B that is unmarked and matches tokA foreach (var tB in ListB.Where(t => !t.Marked).Where(tokA.EqualsTokenValue)) { //counter++; var tokB = tB; // CLOSURE int indB = ListB.IndexOf(tokB); int matchLength = CalculateMatchLength(indA, indB); if (matchLength >= LastMaximumMatch) { var tile = AbstractGSTAlgorithm.CreateTile(ListA, indA, indB, matchLength); AddTileToMatchList(listMatches, matchLength, tile); } } // foreach in B } // foreach in A foreach (var tile in listMatches) { MarkTileAsMatched(tile); ListTiles.Add(tile); } TilesMatchedInLastRun = listMatches; //Console.WriteLine("one run({1}) took {0} ms", watch.ElapsedMilliseconds, counter); }
public Program() { _sendedList = new ListA("postedlist.txt"); for (int i = 0; i < 5; i++) { new Client().StartSpammAsync(); } for (int i = 0; i < 1; i++) { new Client().StartPopulateAsync(); } while (true) { Thread.Sleep(5000); _sendedList.Flush(); Trace.WriteLine("flushed"); } }
/// <summary> /// compares two lists of HashingEntity objects /// </summary> /// <param name="listA"></param> /// <param name="listB"></param> private void CompareLists(IList <HashingEntity> listA, IList <HashingEntity> listB) { foreach (var entityA in listA) { var indA = ListA.IndexOf(entityA.Tokens[0]); //Console.WriteLine("indexA: " + indA); foreach (var entityB in listB) { var indB = ListB.IndexOf(entityB.Tokens[0]); int matchLength = CalculateMatchLength(indA, indB); //Console.WriteLine("indexB: {0}, ML: {1}", indB, matchLength); if (matchLength >= LastMaximumMatch) { var tile = AbstractGSTAlgorithm.CreateTile(ListA, indA, indB, matchLength); AddTileToMatchList(MatchesList, matchLength, tile); } } // foreach in B } // foreach in A }
/// <summary> /// 构造函数 /// </summary> /// <param name="dirA"></param> /// <param name="dirB"></param> public DirComparison(string dirA, string dirB) { this.DirA = dirA; this.DirB = dirB; ListA = DirComparison.Parse(dirA); ListB = DirComparison.Parse(dirB); DiffersInA = new List <DirItem>(); foreach (DirItem item in ListA) { if (!ListB.Contains(item)) { DiffersInA.Add(item); } } DiffersInB = new List <DirItem>(); foreach (DirItem item in ListB) { if (!ListA.Contains(item)) { DiffersInB.Add(item); } } }