Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

gslib::static_container::abstruct_list_node_pool< Value > Class Template Reference

サブクラスはコンストラクタで init() を呼ばなければならない。 More...

#include <list_node_pool.h>

Inheritance diagram for gslib::static_container::abstruct_list_node_pool< Value >:

Inheritance graph
[legend]
Collaboration diagram for gslib::static_container::abstruct_list_node_pool< Value >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef list_link link
typedef list_node< Value > node

Public Member Functions

virtual size_type size () const=0
nodeallocate ()
 メモリ領域の貸与のみ。value のコンストラクタ呼び出しは、ユーザーの責任。

void deallocate (link *first, link *last)
 デストラクタ呼び出しは行わない

void deallocate (link *n)
 デストラクタ呼び出しは行わない

bool full () const
size_type rest () const
 空きノード数取得


Protected Member Functions

 abstruct_list_node_pool ()
virtual nodegetTop ()=0
void init ()

Private Attributes

link free_

Detailed Description

template<typename Value>
class gslib::static_container::abstruct_list_node_pool< Value >

サブクラスはコンストラクタで init() を呼ばなければならない。

Definition at line 69 of file list_node_pool.h.


Member Typedef Documentation

template<typename Value>
typedef list_link gslib::static_container::abstruct_list_node_pool< Value >::link
 

Definition at line 71 of file list_node_pool.h.

Referenced by gslib::static_container::abstruct_list_node_pool< Value >::deallocate(), and gslib::static_container::abstruct_list_node_pool< Value >::rest().

template<typename Value>
typedef list_node< Value > gslib::static_container::abstruct_list_node_pool< Value >::node
 

Definition at line 72 of file list_node_pool.h.

Referenced by gslib::static_container::abstruct_list_node_pool< Value >::allocate(), and gslib::static_container::abstruct_list_node_pool< Value >::init().


Constructor & Destructor Documentation

template<typename Value>
gslib::static_container::abstruct_list_node_pool< Value >::abstruct_list_node_pool  )  [inline, protected]
 

Definition at line 78 of file list_node_pool.h.

00078                                       {
00079             }


Member Function Documentation

template<typename Value>
node* gslib::static_container::abstruct_list_node_pool< Value >::allocate  )  [inline]
 

メモリ領域の貸与のみ。value のコンストラクタ呼び出しは、ユーザーの責任。

Definition at line 98 of file list_node_pool.h.

References gslib::static_container::abstruct_list_node_pool< Value >::free_, gslib::static_container::list_link::isolate(), gslib::static_container::list_link::next, and gslib::static_container::abstruct_list_node_pool< Value >::node.

00098                              {
00099                 if ( free_.next != &free_ ) {
00100                     node* result = static_cast< node* >( free_.next );
00101                     result->isolate();
00102                     return result;
00103                 } else {
00104                     return 0;
00105                 }
00106             }

Here is the call graph for this function:

template<typename Value>
void gslib::static_container::abstruct_list_node_pool< Value >::deallocate link n  )  [inline]
 

デストラクタ呼び出しは行わない

Definition at line 133 of file list_node_pool.h.

References gslib::static_container::abstruct_list_node_pool< Value >::deallocate(), gslib::static_container::abstruct_list_node_pool< Value >::link, and gslib::static_container::list_link::next.

00133                                           {
00134                 deallocate( n, n->next );
00135             }

Here is the call graph for this function:

template<typename Value>
void gslib::static_container::abstruct_list_node_pool< Value >::deallocate link first,
link last
[inline]
 

デストラクタ呼び出しは行わない

Definition at line 112 of file list_node_pool.h.

References gslib::static_container::abstruct_list_node_pool< Value >::free_, gslib::static_container::abstruct_list_node_pool< Value >::link, gslib::static_container::list_link::next, and gslib::static_container::list_link::prev.

Referenced by gslib::static_container::abstruct_list_node_pool< Value >::deallocate().

00112                                                           {
00113                 if ( first == last ) {
00114                     return;
00115                 }
00116                 
00117                 //  「first の直前」と「last」を接続
00118                 first->prev->next = last;
00119                 link* lastPrev = last->prev;
00120                 last->prev = first->prev;
00121 
00122                 //  [ first, lastPrev ] を free_ の終端に接続
00123                 first->prev = free_.prev;
00124                 free_.prev->next = first;
00125                 free_.prev = lastPrev;
00126                 lastPrev->next = &free_;
00127             }

template<typename Value>
bool gslib::static_container::abstruct_list_node_pool< Value >::full  )  const [inline]
 

Return values:
true これ以上挿入不能
false 挿入可能

Definition at line 142 of file list_node_pool.h.

References gslib::static_container::abstruct_list_node_pool< Value >::free_, and gslib::static_container::list_link::next.

00142                               {
00143                 return free_.next == &free_;
00144             }

template<typename Value>
virtual node* gslib::static_container::abstruct_list_node_pool< Value >::getTop  )  [protected, pure virtual]
 

Implemented in gslib::static_container::list_node_pool< Value, Size >.

Referenced by gslib::static_container::abstruct_list_node_pool< Value >::init().

template<typename Value>
void gslib::static_container::abstruct_list_node_pool< Value >::init  )  [inline, protected]
 

Definition at line 82 of file list_node_pool.h.

References gslib::static_container::abstruct_list_node_pool< Value >::free_, gslib::static_container::abstruct_list_node_pool< Value >::getTop(), gslib::static_container::list_link::next, gslib::static_container::abstruct_list_node_pool< Value >::node, gslib::static_container::list_link::prev, and gslib::static_container::abstruct_list_node_pool< Value >::size().

Referenced by gslib::static_container::list_node_pool< Value, Size >::list_node_pool().

00082                            {
00083                 //  すべての要素を free_ に追加
00084                 node* top = getTop();
00085                 free_.next = top;
00086                 free_.prev = top + size() - 1;
00087                 top->prev = &free_;
00088                 free_.prev->next = &free_;
00089                 for ( size_type i = 1; i < size(); ++i ) {
00090                     top[ i - 1 ].next = &top[ i ];
00091                     top[ i ].prev = &top[ i - 1 ];
00092                 }
00093             }

Here is the call graph for this function:

template<typename Value>
size_type gslib::static_container::abstruct_list_node_pool< Value >::rest  )  const [inline]
 

空きノード数取得

Definition at line 147 of file list_node_pool.h.

References gslib::static_container::abstruct_list_node_pool< Value >::free_, gslib::static_container::abstruct_list_node_pool< Value >::link, and gslib::static_container::list_link::next.

00147                                    {
00148                 link* n = free_.next;
00149                 size_type result = 0;
00150                 while ( &free_ != n ) {
00151                     n = n->next;
00152                     ++result;
00153                 }
00154                 return result;
00155             }

template<typename Value>
virtual size_type gslib::static_container::abstruct_list_node_pool< Value >::size  )  const [pure virtual]
 

Implemented in gslib::static_container::list_node_pool< Value, Size >.

Referenced by gslib::static_container::abstruct_list_node_pool< Value >::init().


Member Data Documentation

template<typename Value>
link gslib::static_container::abstruct_list_node_pool< Value >::free_ [private]
 

Definition at line 75 of file list_node_pool.h.

Referenced by gslib::static_container::abstruct_list_node_pool< Value >::allocate(), gslib::static_container::abstruct_list_node_pool< Value >::deallocate(), gslib::static_container::abstruct_list_node_pool< Value >::full(), gslib::static_container::abstruct_list_node_pool< Value >::init(), and gslib::static_container::abstruct_list_node_pool< Value >::rest().


The documentation for this class was generated from the following file:
Generated on Sat Nov 27 15:02:57 2004 for static_container by doxygen 1.3.6