예제 #1
0
        public static bool Insert(HashtableDto[] hashtable, HashtableDto data)
        {
            for (int i = 0; i < Program.TABLE_SIZE; i++)
            {
                int key = HashingJoint(data, i);
                insertCount++;

                if (hashtable[key] == null)
                {
                    hashtable[key] = data;
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        public static bool Insert(HashtableDto[] hashtable, HashtableDto data)
        {
            for (int i = 0; i < hashtable.Length; i++)
            {
                int key = HashingFunction(data, i);
                insertCount++;

                if (hashtable[key] == null)
                {
                    hashtable[key] = data;
                    return(true);
                }
            }

            return(false);
        }
예제 #3
0
        public static bool Search(HashtableDto[] hashtable, HashtableDto data)
        {
            for (int i = 0; i < Program.TABLE_SIZE; i++)
            {
                int key = HashingJoint(data, i);
                searchCount++;

                if (hashtable[key] == data)
                {
                    return(true);
                }
                else if (hashtable[key] == null)
                {
                    return(false);
                }

                searchMissCount++;
            }

            return(false);
        }
예제 #4
0
        public static bool Search(HashtableDto[] hashtable, HashtableDto data)
        {
            for (int i = 0; i < hashtable.Length; i++)
            {
                int key = HashingFunction(data, i);
                searchCount++;

                if (hashtable[key] == data)
                {
                    return(true);
                }
                else if (hashtable[key] == null)
                {
                    return(false);
                }

                searchMissCount++;
            }

            return(false);
        }
예제 #5
0
 private static int Hashing2(HashtableDto data)
 {
     return(Program.LARGEST_PRIME - (data.Key % Program.LARGEST_PRIME));
 }
예제 #6
0
 private static int Hashing1(HashtableDto data)
 {
     return(data.Key % Program.TABLE_SIZE);
 }
예제 #7
0
 private static int HashingJoint(HashtableDto data, int i)
 {
     return((Hashing1(data) + i * Hashing2(data)) % Program.TABLE_SIZE);
 }
예제 #8
0
 private static int HashingFunction(HashtableDto data, int i)
 {
     return((data.Key + i) % Program.TABLE_SIZE);
 }