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

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

?? hat.h

?? vdhl and matlab, i think it good for you
?? H
字號:
#ifndef HAT_H#define HAT_H#include "sysinc.h"/** These macros ensure the these calculations get   inlined even for stupid compilers.*/#define GetTopIndex(i) ((i)>>power)#define GetLeafIndex(i) ((i)&leafMask)/** Minimum hat array will hold 32 *32 = 1024 elements.  Note   that the 32 element leaves will be allocated on demand. */typedef enum { min_hat_size = 32 };#ifndef NULL#define NULL 0#endif/**   This class implements a dynamicly growable array.  Arrays of this   type are particularly useful in code generators, where algorithms   like register range analysis and peephole optimization work best on   arrays of instructions.   This class is implemented by a Hashed Array Tree (see <i>HATs: Hashed   Array Trees - very fast variable length arrays</i> by Edward Sitarski,   published in the "Algorithm Alley" section of Dr. Dobb's Journal,   September 1996).  The code here is derived from the public domain   code published along with this article (e.g., ftp from the Dr. Dobbs   ftp site).   This is a template class.  Some C++ compilers (e.g., Sun) will only   compile template classes with in-line class functions.   This code is fairly tricky.  Memory is only allocated when it is needed   and the addLeaf and resize functions end up being recursive co-routines.   I like to think that my code is more transparent than this, since trickiness   makes code difficult to understand and maintain.  However, I've combed    through this code and run some tests on it and as far as I can tell,   it works correctly.<h4>  Notes</h4><ul><li><p>    Hashed Array Trees (hat)</p><p>      A slightly altered quote from the <i>Hats: Hashed Array Trees</i> article      is included below:</p><p><i>        Although used to implement one dimensional arrays, HATs are        really two dimensional.  A HAT consists of a "Top" array and a        number of "Leaves" which are pointed to by the Top array.  The        number of pointers in the Top array and the number of elements        in each Leaf is the same, and is always a power of 2.</i></p><p><i>        Because the Top and Leaf arrays are powers of 2, you can	efficiently find an element in a HAT using bit operations.	Usually appending elements is very fast since the last leaf	may have empty space.  Less frequently, a new leaf must be	added, which is also very fast and requires no copying.</i></p><p><i>        When the Top array is full, the size of new Top and Leaf	arrays are calculated (e.g., a Top, that is twice as big,	is allocated and enough leaf arrays are allocated to hold	the current data set).  A new Top is allocated.  The existing	data is "appended" to the new hat, allocating new leaves and	deallocating old leaves as the copying is done.</i></p><i>        Recopying only occurs when the Top array is full and this	happens when the number of elements exceeds the square of a	power of two</i></p></li><li><p>    size_t</p><p>      You've got to love C++, it's huge and they constantly add to it.  There      are endless corners of the language that few people know about which      allow people like Al Stevens (a Dr. Dobb's columnist) to count coup on      the rest of us.  One of these obscure features is size_t.  From      section 5.3.2 of The Annotated C++ Reference Manual:</p><p>         ... size_t, an impementation-dependent unsigned integral type         defined in the standard header <stddef.h>.</p>      On most systems this is the local version of "unsigned int".</li><li><p>    Code bloat</p><p>      The Sun compiler has a habbit of in-lining constructors.  As      a result, a lot of code, especially in templates, ends up      in line, exploding the size of the program.</p></li></ul> */template <class T>class Hat{private:    size_t leafSize() const { return 1<<power; /* return 2^power */ }    size_t topSize() const { return 1<<power; /* return 2^power */ }    size_t topIndex( const unsigned i ) const { return GetTopIndex(i); }    size_t leafIndex( const unsigned i ) const { return GetLeafIndex(i); }    /**     Allocate a new HAT and copy the data from "this" HAT     into the new HAT.     */    void resize( const size_t newExpectedSize )    {	size_t	i, leaf_ix;	Hat<T>	hatNew( newExpectedSize );	/* if the new HAT is the same size (e.g., power) as "this"	   HAT, return */	if( hatNew.power == power )	    return;	/* copy the data from "this" hat into the new array */	for( i = 0, leaf_ix = 0; i < numElements; i++ )	    {		hatNew.add_to_end( (*this)[i], 0 );	// append, but do not resize again		leaf_ix++;		// delete the leaves as we go - this decreases memory overhead.		if( leaf_ix == leafSize() )		    {			delete [] top[topIndex(i)];			leaf_ix = 0;		    }	    }	// delete any unused leaves.	for( i = topIndex(numElements); i < topUsed; i++ )	    delete [] top[i];	// assign the new array to the old.	delete top;	top = hatNew.top;	setPower( hatNew.power );	topUsed = hatNew.topUsed;	numAvail = hatNew.numAvail;	// clean up so nothing gets corrupted.	hatNew.numElements = 0;	hatNew.topUsed = 0;	hatNew.top = NULL;    }  // resize    /**     Add a new Leaf to the HAT pointer array and insert the     new data element (aValue) into it.     */    void addLeaf( const T &aValue, const int doResize )    {	/* If the top array is either empty (topUsed == 0) or is full	   topUsed == topSize (no new leaves can be added), reallocate the	   array.  */	if( topUsed % topSize() == 0 )	    {		int	growTop = TRUE;		if( doResize )		    {			resize( numElements );			// Check if after the resize we have room.			if( topIndex(numElements) < topUsed )			    {				(*this)[numElements++] = aValue;				return;			    }			// Check if we have room for a new leaf.			if( topUsed % topSize() != 0 )			    growTop = FALSE;		    }		if( growTop )		    {			// Increase the top array by topSize.			T	**topNew = new T * [ topUsed + topSize() ];			for( size_t i = 0; i < topUsed; i++ )			    topNew[i] = top[i];			delete [] top;			top = topNew;		    }	    }	/* add a new leaf */	top[topUsed] = new T [leafSize()];	top[topUsed][0] = aValue;	numAvail += leafSize();	topUsed++;	numElements++;    } /* addLeaf */    size_t recommendedPower( const size_t s ) const    {	const size_t powerMin = 1; // set a resonable minimum	size_t p;	for( p = powerMin; s > (1<<(p<<1)); p++ )	    ;	return p;    } // recommendedPower    void setPower( const size_t p )    {	power = p;	leafMask = leafSize()-1;    }    void add_to_end( const T &aValue, const int doResize = 1 )    {	if (numElements == numAvail) {	    addLeaf( aValue, doResize );	}	else {	    (*this)[numElements] = aValue;	    numElements++;	}    }    /** top points to leaves */    T	**top;    /** amount of top actually used (number of leaves) */    size_t	topUsed;         /** power of 2 used for leaves and top */    size_t	power;	         /** used to compute the leaf index */    size_t	leafMask;        /** Number of elements used in the array.  numElements        always points to the next free element in the array */    size_t	numElements;     /** number of elements currently allocated in the array */    size_t      numAvail;    public:    void init( const size_t aExpectedSize = min_hat_size )    {	size_t p;	/* get the smallest power of two greater than aExpectedSize */	p = recommendedPower(aExpectedSize);	setPower( p );	numElements = 0;	numAvail = 0;	top = NULL;	topUsed = 0;    } // init  /**     * Hat default constructor (e.g., default since the class definition     * assigns a default value of zero to aExpectedSize).     */    Hat( const size_t aExpectedSize = min_hat_size )    {	init( aExpectedSize );    }    Hat( const Hat<T> &hat )    {	init( 0 );	(*this) = hat;    }    ~Hat()    {	if (top != NULL) {	    for( size_t i = 0; i < topUsed; i++ ) {		if (top[i] != NULL) {		    delete [] top[i];		    top[i] = NULL;		}	    }	    delete [] top;	    top = NULL;	}    }      /**       Insert an element "a" into the array at index       "i".             An empty array is an array with no data elements in it.       This is not necessarily the same as the number of storage       elements currently available in the array.             A data element can be inserted into an empty array at        index 0 (e.g., appended to an empty array).  A data       element can be inserted at the end of the array (that       is array.insert( a, array.length())).  A data element       cannot be inserted beyond array.length() and an attempt       to do so will result in an assert error.             Except for insertion at element 0 of an empty array and       insertion at the end of the array, insert can be an        expensive operation.  All elements from i+1 to the       end of the array are moved up one array location.  */    void insert( const T &a, const size_t i )    {	assert( i <= numElements );	if (numElements == 0 || i == numElements) {	    append( a );	}	else {	    assert( length() > 0 );	    size_t last_ix = length() - 1;	    // Move all data elements from i+1 up by one index	    append( (*this)[last_ix] );  // append the last element to the end of the array	    assert( length() == last_ix + 2 );	    int ix;	    for (ix = last_ix; ix > i; ix--) {		(*this)[ix] = (*this)[ix-1];	    }	    (*this)[i] = a;	}    } // insert  /**        Remove (delete is a reserved word) the element at index "i".       Like insert, this can be an expensive operation.  Unless the       element is at the very end of the array, elements from i+1 to       numElements are moved "down" one element.       It is an error to attempt to remove an element beyond the end       of the array.  It is also an error to remove an element from an       empty array.       */    void remove( const size_t i )    {	assert( length() > 0 );	assert( i < length() );	if (i < length() - 1) {	    int ix;	    for (ix = i; ix < length()-1; ix++) {		(*this)[ix] = (*this)[ix+1];	    }	}	numElements--;    }  // remove  /** remove_n: like remove, but this function removes      more than one item. */    void remove_n( const size_t i, const size_t n)    {	assert( length() > 0 );	assert( i + n <= length() );	if (i + n < length()) {	    int ix;	    for (ix = i; ix < length()-n; ix++) {		(*this)[ix] = (*this)[ix+n];	    }	}	numElements -= n;;	    }    T &operator[](const size_t i)    {	assert( i < numAvail );	return top[GetTopIndex(i)][GetLeafIndex(i)];    }    T operator[](const size_t i) const    {	assert( i < numAvail );	return top[GetTopIndex(i)][GetLeafIndex(i)];    }  /** the at function as an l-value */    T &at(const size_t i)     { 	return (*this)[i];     }  /** return the address of a data element */    T at(const size_t i) const     { 	return (*this)[i];     }  /** return the first data element in the array */    T first() const { 	return (*this)[0];     }  /** Return the last data element in the array */    T last() const { 	return (*this)[numElements-1];     }  /** Add an element to the end of the array */    void append( const T& a ) { 	add_to_end(a);     }  /** return TRUE if there are no data elements      in the array. */    int isEmpty() const { 	return numElements == 0;     }  /** When the number of elements is set to zero,       the array is empty of data, but contains storage.       This is the difference between numElements (the       number of data items) and numAvail, the number of       storage elements available.  */    void set_to_empty() {	numElements = 0;    }  /** Return the number of data elements in the array.       As noted above, this is different from the number       of storage elements.  */    size_t length() const { 	return numElements;     }    void decrement_length( const unsigned int val ) {	if (val <= numElements)	    numElements = numElements - val;	else	    numElements = 0;    } // decrement_length};#undef GetTopIndex#undef GetLeafIndex#endif

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美另类小说视频| 一区二区三区.www| 国产很黄免费观看久久| 亚洲国产成人自拍| 94-欧美-setu| 亚洲在线中文字幕| 欧美大胆人体bbbb| 不卡的av在线播放| 亚洲电影在线播放| 国产亚洲欧美激情| 欧美四级电影在线观看| 经典三级在线一区| 亚洲美女视频在线观看| 亚洲视频 欧洲视频| 日韩欧美国产成人一区二区| 91精品国产色综合久久不卡电影| 国产精品1区二区.| 亚洲国产日韩一级| 亚洲国产成人av网| 日韩不卡在线观看日韩不卡视频| 国产精品私房写真福利视频| 91精品在线一区二区| 99国产精品99久久久久久| 成人国产精品免费观看视频| 国产.欧美.日韩| 蜜桃久久久久久久| 国产精品久久久久9999吃药| 精品日韩在线观看| 欧美精品自拍偷拍| 91在线观看成人| 国产成人精品亚洲午夜麻豆| 粉嫩蜜臀av国产精品网站| 99精品热视频| 91久久免费观看| 不卡的电影网站| 欧美三级资源在线| 99国产精品久久久久久久久久| 色狠狠一区二区三区香蕉| 欧美日本在线播放| 欧美日韩在线电影| 日韩午夜精品视频| 欧美二区三区91| 精品成人一区二区| 欧美videossexotv100| 国产视频一区二区在线| 亚洲免费观看高清完整版在线观看熊| 亚洲动漫第一页| 国产综合久久久久久鬼色| 久久99久国产精品黄毛片色诱| 国产精品66部| 欧美丰满美乳xxx高潮www| 亚洲国产高清aⅴ视频| 亚洲一二三四区| 精品亚洲成a人在线观看| 99国产精品久久久久久久久久| 欧美一区二区三区色| 国产精品国产三级国产| 日韩—二三区免费观看av| 不卡视频一二三四| 日韩午夜在线播放| 亚洲精品菠萝久久久久久久| 亚洲综合在线五月| 国产毛片一区二区| 国产91丝袜在线观看| 欧美日韩一区二区三区不卡| 国产色综合一区| 偷拍与自拍一区| 男女激情视频一区| 国产最新精品免费| 欧美人妇做爰xxxⅹ性高电影| 国产欧美一区二区精品性色超碰| 国产精品久久久久一区二区三区共| 五月天丁香久久| 99re视频精品| 久久久久久久久99精品| 亚洲欧洲成人精品av97| 亚洲精品乱码久久久久| 国产麻豆一精品一av一免费| 欧美卡1卡2卡| 亚洲女同一区二区| 福利一区福利二区| 欧美mv日韩mv国产| 午夜天堂影视香蕉久久| 91网站在线播放| 欧美激情一区二区三区全黄| 久久精品国产99| av一区二区三区在线| 欧美日韩黄视频| 亚洲日本欧美天堂| 岛国精品在线播放| 在线一区二区三区四区五区 | 久久综合色综合88| 国产精品久久久久久妇女6080| 美国十次综合导航| 欧美日韩国产大片| 一区二区三区91| 欧美亚洲一区二区在线| 自拍偷拍欧美激情| 波波电影院一区二区三区| 久久久久久久综合狠狠综合| 久久av老司机精品网站导航| 欧美一区三区四区| 日韩 欧美一区二区三区| 欧美视频一区在线| 亚洲国产一二三| 欧美亚洲图片小说| 亚洲超碰97人人做人人爱| 精品一区二区三区香蕉蜜桃 | 亚洲大片精品永久免费| 日本韩国欧美一区二区三区| 亚洲天堂福利av| 97国产精品videossex| 亚洲另类色综合网站| 色综合久久综合中文综合网| 日韩一区二区不卡| 奇米综合一区二区三区精品视频| 欧美日韩精品欧美日韩精品| 日韩电影在线免费观看| 日韩视频免费直播| 日本不卡视频在线| 日韩视频免费观看高清完整版 | 中文字幕一区在线观看| 成人av电影在线观看| ●精品国产综合乱码久久久久| 94-欧美-setu| 亚洲一区二区精品久久av| 欧美午夜精品理论片a级按摩| 亚洲成人av福利| 欧美一区日本一区韩国一区| 捆绑调教一区二区三区| 久久久久久久综合色一本| 99久久精品久久久久久清纯| 一区二区三区免费观看| 欧美丰满少妇xxxxx高潮对白| 毛片一区二区三区| 欧美精品一区二区三区蜜臀| 高清不卡一二三区| 亚洲一区二区三区四区五区中文 | 中文字幕乱码日本亚洲一区二区| 成人激情小说网站| 一区二区三区在线高清| 欧美一区中文字幕| 国产精品一线二线三线精华| 一区免费观看视频| 欧美精品 国产精品| 国产一区二区三区精品视频| 中文字幕av一区二区三区免费看| 日本韩国欧美在线| 紧缚捆绑精品一区二区| 中文字幕在线不卡一区二区三区 | 亚洲影视在线播放| 日韩一区二区在线观看视频播放| 国产精品91xxx| 亚洲一级片在线观看| 精品国产露脸精彩对白| 97久久精品人人做人人爽| 日韩av一二三| 亚洲国产精品二十页| 欧美人与性动xxxx| 成人动漫在线一区| 日韩不卡一区二区三区| 国产精品国产三级国产aⅴ原创| 91精品婷婷国产综合久久性色| 国产99久久久久| 首页亚洲欧美制服丝腿| 欧美色图天堂网| 免费在线一区观看| 综合在线观看色| 日韩免费视频一区| 色综合中文综合网| 成人黄色在线视频| 日本午夜精品一区二区三区电影| 国产精品网友自拍| 精品三级在线观看| 欧美美女激情18p| 91老师片黄在线观看| 精品一区二区三区香蕉蜜桃| 亚洲无人区一区| 国产精品久久久久久久久动漫 | 三级不卡在线观看| 中文字幕一区二区三区av| 这里只有精品免费| 91美女在线看| 国产一区二区成人久久免费影院 | 亚洲成人激情综合网| 日韩精品一区二| 91美女视频网站| 国产电影一区在线| 一区二区三区四区五区视频在线观看| 久久夜色精品一区| 91麻豆精品国产91久久久使用方法 | 亚洲视频图片小说| 亚洲精品在线一区二区| 制服丝袜亚洲色图| 色呦呦网站一区| 国产馆精品极品| 亚洲国产毛片aaaaa无费看| 国产精品国产三级国产aⅴ入口| 欧美精品 日韩| 在线免费亚洲电影|