/// <summary> Prepare data structures for the pairing of the next round</summary> public virtual void prepareNextRound() { Card card; int i; int numCards = cards.Count; pairdown = false; allow3color = false; allow3colorseq = false; allowteam = false; if (roundNumber == -1 || anyResultsInCurrentRound()) { roundNumber++; } if (unpairedStack == null) { unpairedStack = new SupportClass.ListCollectionSupport(); } if (pairedStack == null) { pairedStack = new SupportClass.ListCollectionSupport(); } unpairedStack.Clear(); pairedStack.Clear(); for (i = 0; i < numCards; i++) { card = (Card)cards[i]; if (flags[0] && roundNumber == 2 && i < acceleratedSplit) { card.pairingScore -= 2; } if (!card.withdrawn && card.getRound(roundNumber).result == Card.UNPLAYED) { card.prepareNextRound(); addCardSorted(card); } } }
private static void downheap(SupportClass.ListCollectionSupport v, Comparitor comp, int k, int N) { System.Object T = v.Get(k - 1); while (k <= N / 2) { int j = k + k; if ((j < N) && (comp.Compare(v.Get(j - 1), v.Get(j)) < 0)) { j++; } if (comp.Compare(T, v.Get(j - 1)) >= 0) { break; } else { v.Set(k - 1, v.Get(j - 1)); k = j; } } v.Set(k - 1, T); }
/// <summary> Method for actually performing the heap sort.</summary> /// <param name="v"> Vector to sort /// </param> /// <param name="comp"> Comparitor to compare the elements of the vector /// </param> /// <exception cref=""> java.lang.Exception Any exception at all /// </exception> /// <seealso cref="Comparitor"> /// </seealso> public static void sort(SupportClass.ListCollectionSupport v, Comparitor comp) { int N = v.Count; if (N < 1) { return; } for (int k = N / 2; k > 0; k--) { downheap(v, comp, k, N); } do { System.Object T; T = v.Get(0); v.Set(0, v.Get(N - 1)); v.Set(N - 1, T); N = N - 1; downheap(v, comp, 1, N); }while (N > 1); }
public Engine() { unpairedStack = new SupportClass.ListCollectionSupport(); pairedStack = new SupportClass.ListCollectionSupport(); }