コード例 #1
0
        public void Swap(T[] items, int x, int y)
        {
            SwapEvent?.Invoke(this, new Tuple <int, int>(x, y));

            T temp = items[x];

            items[x] = items[y];
            items[y] = temp;
        }
コード例 #2
0
 protected void Swap(int posA, int posB)
 {
     if (posA < Items.Count && posB < Items.Count)
     {
         SwapEvent?.Invoke(this, new Tuple <T, T>(Items[posA], Items[posB]));
         SwapCount++;
         var temp = Items[posA];
         Items[posA] = Items[posB];
         Items[posB] = temp;
     }
 }
コード例 #3
0
ファイル: AlgorithmBase.cs プロジェクト: ko4a/Sorter
 protected void Swap(int FirstPosition, int SecondPosition)
 {
     if (FirstPosition < Items.Count && SecondPosition < Items.Count)
     {
         SwapEvent?.Invoke(this, new Tuple <int, int>(FirstPosition, SecondPosition));
         var tmp = Items[FirstPosition];
         Items[FirstPosition]  = Items[SecondPosition];
         Items[SecondPosition] = tmp;
         ++SwapCount;
     }
 }
コード例 #4
0
        public void Swap(int first, int second)
        {
            if (first < Items.Count && second < Items.Count)
            {
                SwapEvent?.Invoke(this, new Tuple <T, T>(Items[first], Items[second]));
                SwapCount++;

                var temp = Items[first];
                Items[first]  = Items[second];
                Items[second] = temp;
            }
        }
コード例 #5
0
    public void Swap(int _withIndex)
    {
        EndCurrentEvent();

        SwapEvent swapEvent = new SwapEvent();

        swapEvent.TargetLocation = gameGrid.GetWorldPositionOfIndex(_withIndex);
        swapEvent.SizeCurve      = MasterManager.instance.BlockEvents.SwapScaleAnimCurve;
        swapEvent.Time           = MasterManager.instance.BlockEvents.SwapEventTime;
        currentEvent             = swapEvent;
        currentEvent.Start(this);
    }
コード例 #6
0
 protected void Swap(int index1, int index2)
 {
     if (index1 < Items.Count && index2 < Items.Count)
     {
         SwapEvent?.Invoke(this, new Tuple <T, T>(Items[index1], Items[index2]));
         T temp = Items[index1];
         Items[index1] = Items[index2];
         Items[index2] = temp;
         SwapCount++;
     }
     else
     {
         throw new ArgumentOutOfRangeException();
     }
 }
コード例 #7
0
        protected void InsertAt(int index1, int index2)
        {
            if (index1 < Items.Count && index2 < Items.Count)
            {
                int step = index1 > index2 ? 1 : -1;
                for (int i = index2; index1 > index2 ? i <index1 : i> index1; i += step)
                {
                    SwapEvent?.Invoke(this, new Tuple <T, T>(Items[i + step], Items[i]));
                    T temp = Items[i + step];
                    Items[i + step] = Items[i];
                    Items[i]        = temp;
                }

                SwapCount++;
            }
            else
            {
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #8
0
ファイル: Sorter.cs プロジェクト: ShockByteX/SortAlgorithms
        private void OnSwap(object sender, Tuple <int, int> e)
        {
            _result.SwapsCount++;

            SwapEvent?.Invoke(this, e);
        }