Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions
SBucketFactory Class Reference

sBucket Factory More...

#include <syzextra.h>

Public Types

typedef Base::value_type Bucket
 

Public Member Functions

 SBucketFactory (const ring r)
 
 ~SBucketFactory ()
 
Bucket getBucket (const ring r, const bool remove=true)
 
void putBucket (const Bucket &bt, const bool replace=false)
 

Private Types

typedef std::stack< sBucket_ptBase
 

Private Member Functions

 SBucketFactory ()
 
 SBucketFactory (const SBucketFactory &)
 
void operator= (const SBucketFactory &)
 

Static Private Member Functions

static Bucket _CreateBucket (const ring r)
 inital allocation for new buckets More...
 
static void _DestroyBucket (Bucket &bt)
 we only expect empty buckets to be left at the end for destructor bt will be set to NULL More...
 

Detailed Description

sBucket Factory

Cleate/store/reuse buckets

Definition at line 75 of file syzextra.h.

Member Typedef Documentation

◆ Base

typedef std::stack<sBucket_pt> SBucketFactory::Base
private

Definition at line 78 of file syzextra.h.

◆ Bucket

typedef Base::value_type SBucketFactory::Bucket

Definition at line 84 of file syzextra.h.

Constructor & Destructor Documentation

◆ SBucketFactory() [1/3]

SBucketFactory::SBucketFactory ( const ring  r)
inline

Definition at line 86 of file syzextra.h.

88  : m_ring(r)
89 #endif
90  {
91  push ( _CreateBucket(r) ); // start with at least one sBucket...?
92  assume( top() != NULL );
93  };
#define assume(x)
Definition: mod2.h:394
static Bucket _CreateBucket(const ring r)
inital allocation for new buckets
#define NULL
Definition: omList.c:10
BEGIN_NAMESPACE_SINGULARXX const ring r
Definition: syzextra.h:48

◆ ~SBucketFactory()

SBucketFactory::~SBucketFactory ( )
inline

Definition at line 95 of file syzextra.h.

96  {
97  while( !empty() )
98  {
99  _DestroyBucket( top() );
100  pop();
101  }
102  }
static void _DestroyBucket(Bucket &bt)
we only expect empty buckets to be left at the end for destructor bt will be set to NULL ...
Definition: syzextra.cc:101

◆ SBucketFactory() [2/3]

SBucketFactory::SBucketFactory ( )
private

◆ SBucketFactory() [3/3]

SBucketFactory::SBucketFactory ( const SBucketFactory )
private

Member Function Documentation

◆ _CreateBucket()

static Bucket SBucketFactory::_CreateBucket ( const ring  r)
staticprivate

inital allocation for new buckets

◆ _DestroyBucket()

void SBucketFactory::_DestroyBucket ( SBucketFactory::Bucket bt)
staticprivate

we only expect empty buckets to be left at the end for destructor bt will be set to NULL

Definition at line 101 of file syzextra.cc.

102 {
103  if( bt != NULL )
104  {
105  assume( _IsBucketEmpty(bt) );
106  sBucketDestroy( &bt );
107  bt = NULL;
108  }
109 }
void sBucketDestroy(sBucket_pt *bucket)
Definition: sbuckets.cc:127
#define NULL
Definition: omList.c:10
assume(R !=NULL)

◆ getBucket()

Bucket SBucketFactory::getBucket ( const ring  r,
const bool  remove = true 
)
inline

Definition at line 104 of file syzextra.h.

105  {
106  assume( r == m_ring );
107 
108  Bucket bt = NULL;
109 
110  if( !empty() )
111  {
112  bt = top();
113 
114  if( remove )
115  pop();
116  }
117  else
118  {
119  bt = _CreateBucket(r);
120 
121  if( !remove )
122  {
123  push(bt);
124  assume( bt == top() );
125  }
126  }
127 
128  assume( bt != NULL );
129  assume( _IsBucketEmpty(bt) );
130  assume( r == _GetBucketRing(bt) );
131 
132  return bt;
133  }
#define assume(x)
Definition: mod2.h:394
static Bucket _CreateBucket(const ring r)
inital allocation for new buckets
#define NULL
Definition: omList.c:10
Base::value_type Bucket
Definition: syzextra.h:84
BEGIN_NAMESPACE_SINGULARXX const ring r
Definition: syzextra.h:48

◆ operator=()

void SBucketFactory::operator= ( const SBucketFactory )
private

◆ putBucket()

void SBucketFactory::putBucket ( const Bucket bt,
const bool  replace = false 
)
inline

Definition at line 136 of file syzextra.h.

137  {
138  assume( bt != NULL );
139  assume( _IsBucketEmpty(bt) );
140  assume( m_ring == _GetBucketRing(bt) );
141 
142  if( empty() )
143  push( bt );
144  else
145  {
146  if( replace )
147  top() = bt;
148  else
149  {
150  if( bt != top() )
151  push( bt );
152  }
153  }
154 
155  assume( bt == top() );
156  }
#define assume(x)
Definition: mod2.h:394
#define NULL
Definition: omList.c:10

The documentation for this class was generated from the following files: