// // Basic Summary: // // Include file for linked chunk definition // // Copyright: // // Copyright 1993 Ron Burback // Copyright 1993 Objects Plus // All rights reserved // // Description: // // A linked chunk is a simple link list of fixed chunks. // As more space is needed, a new section is allocated and linked // // Data elemnents: // // There are two data storage elements. // One to store the fixed storage of this section. // The other to store the locations of the next chunk. // // Methods: // // The methods are // linked_chunk(); - standard constructor // ~linked_chunk(); - standard disctructor // void * get(natural n); - get and remove the nth element // void * peak(natural n); - get the nth element // Boolean full () ; - is it full // Boolean empty () ; - is it empty // Boolean bounds(natural n) ; - the current bounds of the array. // void set(natural n,void * e) ; - insert at nth location, moving the // rest of the elements down. // void replace(natural n,void * e) ; - replace the nth location // natural length() ; // linked_chunk * location(natural n) ; - the chunk that contains the nth element // linked_chunk * shrink(); - remove unused space // void expand(natural n); - grow // natural offset(linked_chunk * c) ; the base location represented by this chunk // // static Boolean test(); = quality assurance test // // The daughter class cursor, points to the chunk that materilizes a location // This is a simple optimization. It keeps track of the last location in the // list that was used and starts the search from there // // Macro definitions: none // // // Class definition: // // linked_chunk // #ifndef _OP_CURSOR #define _OP_CURSOR class cursor { friend class linked_chunk ; friend class dynamic_array ; private: natural offset ; linked_chunk * base ; public: static pool ThePool ; static char * version ; cursor(); ~cursor(); void * operator new(size_t) { return ThePool.alloc(); }; void operator delete(void * p) { ThePool.free(p); }; }; #endif #ifndef _OP_LINKEDCHUNK #define _OP_LINKEDCHUNK class linked_chunk { friend class dynamic_array ; private: circular_buffer * storage ; linked_chunk * next ; public: static pool ThePool ; static char * version ; linked_chunk(); ~linked_chunk(); void * get(natural n); void * peak(natural n); Boolean full () ; Boolean empty () ; Boolean bounds(natural n) ; void set(natural n,void * e) ; void replace(natural n,void * e) ; natural length() ; linked_chunk * location(natural n) ; linked_chunk * shrink(); void expand(natural n); natural offset(linked_chunk * c) ; cursor * point (natural offset, natural n) ; void * operator new(size_t) { return ThePool.alloc(); }; void operator delete(void * p) { ThePool.free(p); }; static Boolean test(); }; #endif