X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=src%2FBufferTop.h;h=7906a31c8bac3bc5e54b024c8af7e121ea6289cc;hb=HEAD;hp=f399bc2a0e206a51095af9c18ec980450b6141b4;hpb=e45132acdb58c076d5e06849fa51c26de9a7486d;p=cgds.git diff --git a/src/BufferTop.h b/src/BufferTop.h index f399bc2..7906a31 100644 --- a/src/BufferTop.h +++ b/src/BufferTop.h @@ -18,7 +18,7 @@ typedef struct BufferTop { UInt capacity; ///< Buffer capacity (in items count). OrderType bType; ///< Type of buffer: keep max or min items (MAX_T or MIN_T). - Heap* heap; ///< Item-ValueS are internally organized into a heap. + Heap* heap; ///< Items + values are internally organized into a heap. } BufferTop; /** @@ -41,9 +41,7 @@ BufferTop* _buffertop_new( * Usage: BufferTop* buffertop_new( type, UInt capacity, OrderTypebType, UInt arity) */ #define buffertop_new(type, capacity, bType, arity) \ -{ \ - _buffertop_new(sizeof(type), capacity, bType, arity); \ -} + _buffertop_new(sizeof(type), capacity, bType, arity) /** * @brief Copy constructor (shallow copy, ok for basic types). @@ -92,14 +90,14 @@ void _buffertop_tryadd( */ #define buffertop_tryadd(bufferTop, item, value) \ { \ - typeof((item)) tmp = item; \ + typeof(item) tmp = item; \ _buffertop_tryadd(bufferTop, &tmp, value); \ } /** * @brief Return the top ("worst among best") ItemValue inside current buffer. */ -ItemValue* buffertop_first_raw( +ItemValue _buffertop_first( BufferTop* bufferTop ///< "this" pointer. ); @@ -108,12 +106,12 @@ ItemValue* buffertop_first_raw( * @param bufferTop "this" pointer. * @param item_ Variable to be assigned. * - * Usage: void buffertop_first(BufferTop* bufferTop, void item) + * Usage: void buffertop_first(BufferTop* bufferTop, void item_) */ #define buffertop_first(bufferTop, item_) \ { \ - void* pItem = buffertop_first_raw(bufferTop)->item; \ - item_ = *((typeof(&item_))pItem); \ + ItemValue iv = _buffertop_first(bufferTop); \ + item_ = *((typeof(item_)*)(iv.item)); \ } /**