SIMLIB/C++ 3.09
Loading...
Searching...
No Matches
simlib3::CalendarQueue Class Reference

CQ implementation of calendar. More...

Inheritance diagram for simlib3::CalendarQueue:
Collaboration diagram for simlib3::CalendarQueue:

Public Member Functions

virtual void ScheduleAt (Entity *p, double t) override
 enqueue
virtual Entity * Get (Entity *p) override
 dequeue
virtual Entity * GetFirst () override
 dequeue first
virtual void clear (bool destroy=false) override
 remove all
virtual const char * Name () override
virtual void debug_print () override
 for debugging only
void visualize (const char *msg)
 CalendarQueue::visualize – output suitable for Gnuplot.
Public Member Functions inherited from simlib3::Calendar
bool Empty () const
unsigned Size () const
double MinTime () const
 time of activation of first item

Static Public Member Functions

static CalendarQueue * create ()
 create calendar instance
Static Public Member Functions inherited from simlib3::Calendar
static Calendar * instance ()
 interface to singleton instance
static bool instance_exists ()
 check if the instance exists

Private Types

typedef CalendarListImplementation BucketList

Private Member Functions

bool list_impl ()
int time2bucket (double t)
 Convert time to bucket number.
double time2bucket_top (double t)
 Compute bucket top limit.
double estimate_bucket_width ()
 compute new bucket width — EXPERIMENTAL
void switchtocq ()
 switch to calendar queue implementation
void switchtolist ()
 switch to list implementation
 CalendarQueue ()
 Initialize calendar queue.
 ~CalendarQueue ()
 Destroy calendar queue.
void Resize (int grow=0)
 Resize bucket array.
void SearchMinTime (double starttime)
 compute new mintime

Private Attributes

BucketList * buckets
BucketList list
unsigned nbuckets
unsigned hi_bucket_mark
unsigned low_bucket_mark
unsigned nextbucket
unsigned numop
double bucket_width
double buckettop
double last_dequeue_time
double sumdelta
unsigned ndelta

Additional Inherited Members

Protected Member Functions inherited from simlib3::Calendar
void SetMinTime (double t)
 set cache for faster access
 Calendar ()
virtual ~Calendar ()
 clear is called in derived class dtr
Static Protected Member Functions inherited from simlib3::Calendar
static void delete_instance ()
 destroy single instance
Protected Attributes inherited from simlib3::Calendar
unsigned _size
 number of scheduled items

Detailed Description

CQ implementation of calendar.

Definition at line 547 of file calendar.cc.

Member Typedef Documentation

◆ BucketList

Constructor & Destructor Documentation

◆ CalendarQueue()

simlib3::CalendarQueue::CalendarQueue ( )
private

◆ ~CalendarQueue()

simlib3::CalendarQueue::~CalendarQueue ( )
private

Destroy calendar queue.

Definition at line 1121 of file calendar.cc.

References simlib3::allocator, clear(), simlib3::EventNoticeAllocator::clear(), and Dprintf.

Member Function Documentation

◆ clear()

void simlib3::CalendarQueue::clear ( bool destroy = false)
overridevirtual

◆ create()

CalendarQueue * simlib3::CalendarQueue::create ( )
inlinestatic

◆ debug_print()

void simlib3::CalendarQueue::debug_print ( )
overridevirtual

◆ estimate_bucket_width()

double simlib3::CalendarQueue::estimate_bucket_width ( )
private

◆ Get()

◆ GetFirst()

◆ list_impl()

bool simlib3::CalendarQueue::list_impl ( )
inlineprivate

Definition at line 564 of file calendar.cc.

References buckets.

Referenced by clear(), Get(), GetFirst(), ScheduleAt(), and visualize().

◆ Name()

virtual const char * simlib3::CalendarQueue::Name ( )
inlineoverridevirtual

Implements simlib3::Calendar.

Definition at line 604 of file calendar.cc.

◆ Resize()

◆ ScheduleAt()

◆ SearchMinTime()

◆ switchtocq()

◆ switchtolist()

void simlib3::CalendarQueue::switchtolist ( )
private

◆ time2bucket()

int simlib3::CalendarQueue::time2bucket ( double t)
inlineprivate

Convert time to bucket number.

Definition at line 567 of file calendar.cc.

References bucket_width, nbuckets, and t.

Referenced by estimate_bucket_width(), Get(), GetFirst(), Resize(), ScheduleAt(), SearchMinTime(), and switchtocq().

◆ time2bucket_top()

double simlib3::CalendarQueue::time2bucket_top ( double t)
inlineprivate

Compute bucket top limit.

Definition at line 575 of file calendar.cc.

References bucket_width, and t.

Referenced by estimate_bucket_width(), and SearchMinTime().

◆ visualize()

Member Data Documentation

◆ bucket_width

double simlib3::CalendarQueue::bucket_width
private

◆ buckets

◆ buckettop

double simlib3::CalendarQueue::buckettop
private

Definition at line 558 of file calendar.cc.

Referenced by CalendarQueue(), and SearchMinTime().

◆ hi_bucket_mark

unsigned simlib3::CalendarQueue::hi_bucket_mark
private

Definition at line 552 of file calendar.cc.

Referenced by CalendarQueue(), Resize(), ScheduleAt(), and switchtocq().

◆ last_dequeue_time

double simlib3::CalendarQueue::last_dequeue_time
private

Definition at line 559 of file calendar.cc.

Referenced by CalendarQueue(), clear(), GetFirst(), and switchtocq().

◆ list

BucketList simlib3::CalendarQueue::list
private

Definition at line 550 of file calendar.cc.

Referenced by clear(), Get(), GetFirst(), ScheduleAt(), switchtocq(), and switchtolist().

◆ low_bucket_mark

unsigned simlib3::CalendarQueue::low_bucket_mark
private

Definition at line 553 of file calendar.cc.

Referenced by CalendarQueue(), Get(), GetFirst(), Resize(), and switchtocq().

◆ nbuckets

unsigned simlib3::CalendarQueue::nbuckets
private

◆ ndelta

unsigned simlib3::CalendarQueue::ndelta
private

Definition at line 561 of file calendar.cc.

Referenced by CalendarQueue(), clear(), estimate_bucket_width(), GetFirst(), and switchtocq().

◆ nextbucket

unsigned simlib3::CalendarQueue::nextbucket
private

Definition at line 554 of file calendar.cc.

Referenced by CalendarQueue(), GetFirst(), and SearchMinTime().

◆ numop

unsigned simlib3::CalendarQueue::numop
private

Definition at line 556 of file calendar.cc.

Referenced by CalendarQueue(), clear(), Get(), GetFirst(), Resize(), ScheduleAt(), switchtocq(), and visualize().

◆ sumdelta

double simlib3::CalendarQueue::sumdelta
private

Definition at line 560 of file calendar.cc.

Referenced by CalendarQueue(), clear(), estimate_bucket_width(), GetFirst(), and switchtocq().


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