예제 #1
0
        public void Swap(int firstIndex, int secondIndex)
        {
            // Alg1_Practicum_Utils.Globals.Alg1NawArrayMethodCalled = true;
            // if (Alg1_Practicum_Utils.Globals.ShowAlg1NawArrayAlerts) { System.Console.WriteLine("\n\n!!!! Aanroepen van methodes op Alg1NawArray Class is niet toegestaan"); }
            // Toegestaan om correct aantal swaps bij sorteren toe te staan.

            var lowestIndex  = firstIndex < secondIndex ? firstIndex : secondIndex;
            var highestIndex = firstIndex > secondIndex ? firstIndex : secondIndex;

            if (Logger.Instance.Enabled)
            {
                Logger.Instance.Log(
                    new LogItem
                {
                    NewNaw1     = _array[highestIndex],
                    OldNaw1     = _array[lowestIndex],
                    Index1      = lowestIndex,
                    NewNaw2     = _array[lowestIndex],
                    OldNaw2     = _array[highestIndex],
                    Index2      = highestIndex,
                    ArrayAction = ArrayAction.SWAP
                });
            }

            NAW temp = _array[firstIndex];

            _array[firstIndex]  = _array[secondIndex];
            _array[secondIndex] = temp;
        }
        public static NAW GenerateNaw()
        {
            var naw = new NAW();

            naw.Naam       = RandomGenerator.generateString(_random.Next(1, 5));
            naw.Adres      = RandomGenerator.generateString(_random.Next(1, 5));
            naw.Woonplaats = RandomGenerator.generateString(_random.Next(1, 5));

            return(naw);
        }
예제 #3
0
        public HashItem <K, V> this[int index]
        {
            get
            {
                if (_array != null && Logger.Instance.Enabled)
                {
                    NAW nawValue;
                    if (_array[index] != null)
                    {
                        nawValue = new NAW("HashLink", "empty", "empty");
                    }
                    else
                    {
                        nawValue = new NAW("empty", "empty", "empty");
                    }
                    Logger.Instance.Log(

                        new LogItem
                    {
                        NewNaw1     = nawValue,
                        Index1      = index,
                        ArrayAction = ArrayAction.GET
                    }
                        );
                }
                return(_array[index]);
            }
            set
            {
                if (_array != null && Logger.Instance.Enabled)
                {
                    NAW nawValue;
                    if (_array[index] != null)
                    {
                        nawValue = new NAW("HashLink", "empty", "empty");
                    }
                    else
                    {
                        nawValue = new NAW("empty", "empty", "empty");
                    }

                    Logger.Instance.Log(
                        new LogItem
                    {
                        NewNaw1     = nawValue,
                        OldNaw1     = nawValue,
                        Index1      = index,
                        ArrayAction = ArrayAction.SET
                    }
                        );
                }

                _array[index] = value;
            }
        }
예제 #4
0
 public HashItem(string key, NAW value)
 {
     Key       = key;
     Value     = value;
     IsDeleted = false;
 }