亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? quadraticprobinghashtable.java

?? Data StructuresAnd Algorithm Analysis In Java Source Code
?? JAVA
字號:
    package DataStructures;

    // QuadraticProbingHashTable abstract class
    //
    // CONSTRUCTION: with an approximate initial size or a default.
    //
    // ******************PUBLIC OPERATIONS*********************
    // void insert( x )       --> Insert x
    // void remove( x )       --> Remove x
    // Hashable find( x )     --> Return item that matches x
    // void makeEmpty( )      --> Remove all items
    // int hash( String str, int tableSize )
    //                        --> Static method to hash strings

    /**
     * Probing table implementation of hash tables.
     * Note that all "matching" is based on the equals method.
     * @author Mark Allen Weiss
     */
    public class QuadraticProbingHashTable
    {
        /**
         * Construct the hash table.
         */
        public QuadraticProbingHashTable( )
        {
            this( DEFAULT_TABLE_SIZE );
        }

        /**
         * Construct the hash table.
         * @param size the approximate initial size.
         */
        public QuadraticProbingHashTable( int size )
        {
            allocateArray( size );
            makeEmpty( );
        }

        /**
         * Insert into the hash table. If the item is
         * already present, do nothing.
         * @param x the item to insert.
         */
        public void insert( Hashable x )
        {
                // Insert x as active
            int currentPos = findPos( x );
            if( isActive( currentPos ) )
                return;

            array[ currentPos ] = new HashEntry( x, true );

                // Rehash; see Section 5.5
            if( ++currentSize > array.length / 2 )
                rehash( );
        }

        /**
         * Expand the hash table.
         */
        private void rehash( )
        {
            HashEntry [ ] oldArray = array;

                // Create a new double-sized, empty table
            allocateArray( nextPrime( 2 * oldArray.length ) );
            currentSize = 0;

                // Copy table over
            for( int i = 0; i < oldArray.length; i++ )
                if( oldArray[ i ] != null && oldArray[ i ].isActive )
                    insert( oldArray[ i ].element );

            return;
        }

        /**
         * Method that performs quadratic probing resolution.
         * @param x the item to search for.
         * @return the position where the search terminates.
         */
        private int findPos( Hashable x )
        {
/* 1*/      int collisionNum = 0;
/* 2*/      int currentPos = x.hash( array.length );

/* 3*/      while( array[ currentPos ] != null &&
                    !array[ currentPos ].element.equals( x ) )
            {
/* 4*/          currentPos += 2 * ++collisionNum - 1;  // Compute ith probe
/* 5*/          if( currentPos >= array.length )       // Implement the mod
/* 6*/              currentPos -= array.length;
            }

/* 7*/      return currentPos;
        }

        /**
         * Remove from the hash table.
         * @param x the item to remove.
         */
        public void remove( Hashable x )
        {
            int currentPos = findPos( x );
            if( isActive( currentPos ) )
                array[ currentPos ].isActive = false;
        }

        /**
         * Find an item in the hash table.
         * @param x the item to search for.
         * @return the matching item.
         */
        public Hashable find( Hashable x )
        {
            int currentPos = findPos( x );
	    return isActive( currentPos ) ? array[ currentPos ].element : null;
        }

        /**
         * Return true if currentPos exists and is active.
         * @param currentPos the result of a call to findPos.
         * @return true if currentPos is active.
         */
        private boolean isActive( int currentPos )
        {
            return array[ currentPos ] != null && array[ currentPos ].isActive;
        }

        /**
         * Make the hash table logically empty.
         */
        public void makeEmpty( )
        {
            currentSize = 0;
            for( int i = 0; i < array.length; i++ )
                array[ i ] = null;
        }

        /**
         * A hash routine for String objects.
         * @param key the String to hash.
         * @param tableSize the size of the hash table.
         * @return the hash value.
         */
        public static int hash( String key, int tableSize )
        {
            int hashVal = 0;

            for( int i = 0; i < key.length( ); i++ )
                hashVal = 37 * hashVal + key.charAt( i );

            hashVal %= tableSize;
            if( hashVal < 0 )
                hashVal += tableSize;

            return hashVal;
        }

        private static final int DEFAULT_TABLE_SIZE = 11;

            /** The array of elements. */
        private HashEntry [ ] array;   // The array of elements
        private int currentSize;       // The number of occupied cells

        /**
         * Internal method to allocate array.
         * @param arraySize the size of the array.
         */
        private void allocateArray( int arraySize )
        {
            array = new HashEntry[ arraySize ];
        }

        /**
         * Internal method to find a prime number at least as large as n.
         * @param n the starting number (must be positive).
         * @return a prime number larger than or equal to n.
         */
        private static int nextPrime( int n )
        {
            if( n % 2 == 0 )
                n++;

            for( ; !isPrime( n ); n += 2 )
                ;

            return n;
        }

        /**
         * Internal method to test if a number is prime.
         * Not an efficient algorithm.
         * @param n the number to test.
         * @return the result of the test.
         */
        private static boolean isPrime( int n )
        {
            if( n == 2 || n == 3 )
                return true;

            if( n == 1 || n % 2 == 0 )
                return false;

            for( int i = 3; i * i <= n; i += 2 )
                if( n % i == 0 )
                    return false;

            return true;
        }


        // Simple main
        public static void main( String [ ] args )
        {
            QuadraticProbingHashTable H = new QuadraticProbingHashTable( );

            final int NUMS = 4000;
            final int GAP  =   37;

            System.out.println( "Checking... (no more output means success)" );


            for( int i = GAP; i != 0; i = ( i + GAP ) % NUMS )
                H.insert( new MyInteger( i ) );
            for( int i = 1; i < NUMS; i+= 2 )
                H.remove( new MyInteger( i ) );

            for( int i = 2; i < NUMS; i+=2 )
                if( ((MyInteger)(H.find( new MyInteger( i ) ))).intValue( ) != i )
                    System.out.println( "Find fails " + i );

            for( int i = 1; i < NUMS; i+=2 )
            {
                if( H.find( new MyInteger( i ) ) != null )
                    System.out.println( "OOPS!!! " +  i  );
            }
        }

    }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品正在播放| 精品国产一区久久| 中文字幕中文乱码欧美一区二区| 亚洲图片另类小说| 狠狠狠色丁香婷婷综合激情 | 一区二区三区四区乱视频| 秋霞影院一区二区| 色综合激情久久| 国产欧美日韩精品一区| 毛片av一区二区| 欧美亚洲综合在线| 国产精品理论在线观看| 激情图片小说一区| 日韩一级片在线观看| 亚洲福利电影网| 91蝌蚪porny| 中文字幕制服丝袜一区二区三区| 久久国产精品区| 777色狠狠一区二区三区| 亚洲精品乱码久久久久久| 成人免费视频免费观看| 久久免费国产精品| 久久精品国产一区二区三| 欧美日韩精品一二三区| 亚洲一区在线看| 成人h精品动漫一区二区三区| 久久综合久色欧美综合狠狠| 蜜桃av一区二区| 欧美一级理论片| 久久99在线观看| 欧美成人一区二区三区| 美腿丝袜在线亚洲一区| 日韩欧美123| 麻豆精品一二三| 日韩美女一区二区三区四区| 久久不见久久见免费视频7| 欧美成人伊人久久综合网| 精东粉嫩av免费一区二区三区| 日韩一区二区电影在线| 激情综合网激情| 久久久久99精品一区| 成人亚洲精品久久久久软件| 国产精品免费看片| 一本到不卡精品视频在线观看| 亚洲久本草在线中文字幕| 欧美亚洲综合网| 爽爽淫人综合网网站| 精品蜜桃在线看| 成人免费看视频| 亚洲黄一区二区三区| 欧美久久久久中文字幕| 日本特黄久久久高潮| 久久久久久久综合日本| 91色乱码一区二区三区| 天天爽夜夜爽夜夜爽精品视频| 日韩情涩欧美日韩视频| 成人精品鲁一区一区二区| 最新中文字幕一区二区三区| 欧美日韩一级二级| 精品夜夜嗨av一区二区三区| 国产精品不卡视频| 欧美另类变人与禽xxxxx| 国产精品亚洲一区二区三区妖精| 国产精品美女久久久久久| 欧美三级电影网| 国产suv精品一区二区6| 亚洲国产视频在线| 久久精品亚洲精品国产欧美| 日本道色综合久久| 九色porny丨国产精品| 亚洲精品水蜜桃| 精品粉嫩超白一线天av| 色综合天天综合色综合av| 秋霞国产午夜精品免费视频| 国产精品久久看| 日韩美女主播在线视频一区二区三区| 成人app网站| 蜜臀久久99精品久久久画质超高清| 国产日韩av一区二区| 欧美日韩极品在线观看一区| 东方欧美亚洲色图在线| 日韩不卡一区二区| 亚洲免费av高清| 国产日韩精品一区| 欧美国产日韩a欧美在线观看| 欧美日韩精品三区| av在线一区二区| 国产一区二区精品在线观看| 中文字幕一区视频| 久久久久久久久99精品| 91精品国产免费| 欧美影院精品一区| 不卡视频在线观看| 国产精品亚洲第一区在线暖暖韩国| 亚洲国产精品影院| 亚洲男同性恋视频| 国产欧美中文在线| 欧美成人女星排行榜| 欧美日韩你懂的| 色婷婷av久久久久久久| 不卡的av网站| 国产成人av电影在线| 国产在线看一区| 麻豆91在线播放免费| 日本伊人色综合网| 午夜久久久影院| 天堂久久久久va久久久久| 一区二区三区欧美| 国产精品国产三级国产| 国产精品欧美极品| 亚洲国产精品成人综合色在线婷婷| 日韩精品一区二| 欧美tickling网站挠脚心| 91精品国产色综合久久| 欧美丰满一区二区免费视频 | 国产乱子伦视频一区二区三区| 奇米一区二区三区| 日本亚洲欧美天堂免费| 日韩av在线播放中文字幕| 日本aⅴ免费视频一区二区三区| 亚洲成人免费看| 三级一区在线视频先锋 | 在线看国产一区| 色香蕉成人二区免费| 91精品福利视频| 欧美日韩国产综合一区二区| 欧美精品久久天天躁| 日韩视频在线一区二区| 337p粉嫩大胆噜噜噜噜噜91av| 欧美mv日韩mv亚洲| 国产午夜精品福利| 中文字幕亚洲在| 亚洲国产精品久久久久秋霞影院| 午夜伊人狠狠久久| 久久成人综合网| 成人av小说网| 在线观看不卡一区| 日韩午夜激情av| 国产精品私房写真福利视频| 亚洲精品欧美综合四区| 日韩国产高清在线| 国产一区不卡视频| 91丨porny丨首页| 欧美日韩久久一区二区| 337p粉嫩大胆噜噜噜噜噜91av| 国产精品午夜电影| 日欧美一区二区| 国产福利一区在线观看| 色综合天天综合色综合av| 日韩一级完整毛片| 中文字幕+乱码+中文字幕一区| √…a在线天堂一区| 日本va欧美va精品| 成人免费av网站| 欧美电影影音先锋| 国产精品久久久久影院亚瑟 | 日韩国产高清影视| 国产91精品一区二区麻豆亚洲| 色婷婷综合五月| xfplay精品久久| 一区二区三区美女| 高清不卡一区二区在线| 在线亚洲高清视频| 国产亚洲欧美在线| 亚洲成av人片在线| 成人精品在线视频观看| 欧美一区二区在线免费观看| 中文字幕亚洲一区二区av在线 | 国产色一区二区| 水蜜桃久久夜色精品一区的特点| 国产不卡在线一区| 日韩欧美国产电影| 亚洲一区二区三区四区的| 国产高清不卡一区二区| 91精品国产色综合久久不卡蜜臀 | 国产麻豆视频一区二区| 欧美美女bb生活片| 亚洲欧美日韩电影| 国产成人啪免费观看软件| 欧美一区二区不卡视频| 亚洲精品乱码久久久久久| 国产成人小视频| 日韩精品中午字幕| 日韩高清不卡一区| 欧美亚洲一区二区在线观看| 国产精品三级视频| 国产大陆a不卡| 精品日韩一区二区三区免费视频| 天天综合网天天综合色| 在线亚洲高清视频| 亚洲另类色综合网站| 99国产精品国产精品毛片| 欧美激情中文字幕一区二区| 国内精品久久久久影院色| 欧美变态tickling挠脚心| 另类中文字幕网| 久久久久亚洲综合| 国产美女娇喘av呻吟久久| 久久久久青草大香线综合精品| 国产一区二区中文字幕|