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 69 of file syzextra.h.

Member Typedef Documentation

◆ Base

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

Definition at line 72 of file syzextra.h.

◆ Bucket

typedef Base::value_type SBucketFactory::Bucket

Definition at line 75 of file syzextra.h.

Constructor & Destructor Documentation

◆ SBucketFactory() [1/3]

SBucketFactory::SBucketFactory ( const ring  r)
inline

Definition at line 77 of file syzextra.h.

78  {
79  push ( _CreateBucket(r) ); // start with at least one sBucket...?
80  assume( top() != NULL );
81  };
#define assume(x)
Definition: mod2.h:390
static Bucket _CreateBucket(const ring r)
inital allocation for new buckets
#define NULL
Definition: omList.c:12

◆ ~SBucketFactory()

SBucketFactory::~SBucketFactory ( )
inline

Definition at line 83 of file syzextra.h.

84  {
85  while( !empty() )
86  {
87  _DestroyBucket( top() );
88  pop();
89  }
90  }
static void _DestroyBucket(Bucket &bt)
we only expect empty buckets to be left at the end for destructor bt will be set to NULL ...

◆ 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()

static void SBucketFactory::_DestroyBucket ( Bucket bt)
staticprivate

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

◆ getBucket()

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

Definition at line 92 of file syzextra.h.

93  {
94  Bucket bt = NULL;
95 
96  if( !empty() )
97  {
98  bt = top();
99 
100  if( remove )
101  pop();
102  }
103  else
104  {
105  bt = _CreateBucket(r);
106 
107  if( !remove )
108  {
109  push(bt);
110  assume( bt == top() );
111  }
112  }
113 
114  assume( bt != NULL );
115 
116  return bt;
117  }
#define assume(x)
Definition: mod2.h:390
static Bucket _CreateBucket(const ring r)
inital allocation for new buckets
#define NULL
Definition: omList.c:12
Base::value_type Bucket
Definition: syzextra.h:75

◆ operator=()

void SBucketFactory::operator= ( const SBucketFactory )
private

◆ putBucket()

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

Definition at line 120 of file syzextra.h.

121  {
122  assume( bt != NULL );
123 
124  if( empty() )
125  push( bt );
126  else
127  {
128  if( replace )
129  top() = bt;
130  else
131  {
132  if( bt != top() )
133  push( bt );
134  }
135  }
136 
137  assume( bt == top() );
138  }
#define assume(x)
Definition: mod2.h:390
#define NULL
Definition: omList.c:12

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