クラス sc_core::sc_ppq_base

#include <sc_pq.h>

sc_core::sc_ppq_baseに対する継承グラフ

Inheritance graph
[凡例]

すべてのメンバ一覧

Public 型

typedef int(* compare_fn_t )(const void *, const void *)

Public メソッド

 sc_ppq_base (int sz, compare_fn_t cmp)
 ~sc_ppq_base ()
void * top () const
void * extract_top ()
void insert (void *elem)
int size () const
bool empty () const

Protected メソッド

int parent (int i) const
int left (int i) const
int right (int i) const
void heapify (int i)

Private 変数

void ** m_heap
int m_size_alloc
int m_heap_size
compare_fn_t m_compar


説明

sc_pq.h60 行で定義されています。


型定義

typedef int(* sc_core::sc_ppq_base::compare_fn_t)(const void *, const void *)


コンストラクタとデストラクタ

sc_core::sc_ppq_base::sc_ppq_base ( int  sz,
compare_fn_t  cmp 
)

sc_core::sc_ppq_base::~sc_ppq_base (  ) 

sc_pq.cpp65 行で定義されています。

00066 {
00067     delete[] m_heap;
00068 }


関数

void* sc_core::sc_ppq_base::top (  )  const [inline]

sc_core::sc_ppq< T >, sc_core::sc_ppq< sc_core::sc_time * >, と sc_core::sc_ppq< sc_core::sc_event_timed * >で再定義されています。

sc_pq.h70 行で定義されています。

00071         { return m_heap[1]; }

void * sc_core::sc_ppq_base::extract_top (  ) 

sc_core::sc_ppq< T >, sc_core::sc_ppq< sc_core::sc_time * >, と sc_core::sc_ppq< sc_core::sc_event_timed * >で再定義されています。

sc_pq.cpp71 行で定義されています。

00072 {
00073     assert( m_heap_size > 0 );
00074     void* topelem = m_heap[1];
00075     m_heap[1] = m_heap[m_heap_size];
00076     m_heap_size --;
00077     heapify( 1 );
00078     return topelem;
00079 }

void sc_core::sc_ppq_base::insert ( void *  elem  ) 

sc_pq.cpp82 行で定義されています。

00083 {
00084     m_heap_size ++;
00085     int i = m_heap_size;
00086 
00087     // resize the heap in case there's not enough memory
00088     if( m_heap_size > m_size_alloc ) {
00089         m_size_alloc += m_size_alloc / 2;
00090         void** new_heap = new void*[m_size_alloc + 1];
00091         for( int j = 1; j < m_heap_size; ++ j ) {
00092             new_heap[j] = m_heap[j];
00093         }
00094         delete[] m_heap;
00095         m_heap = new_heap;
00096     }
00097 
00098     while( (i > 1) && (m_compar( m_heap[parent( i )], elem ) < 0) ) {
00099         m_heap[i] = m_heap[parent( i )];
00100         i = parent( i );
00101     }
00102     m_heap[i] = elem;
00103 }

int sc_core::sc_ppq_base::size (  )  const [inline]

sc_pq.h77 行で定義されています。

00078         { return m_heap_size; }

bool sc_core::sc_ppq_base::empty (  )  const [inline]

sc_pq.h80 行で定義されています。

00081         { return (m_heap_size == 0); }

int sc_core::sc_ppq_base::parent ( int  i  )  const [inline, protected]

sc_pq.h85 行で定義されています。

00086         { return i >> 1; }

int sc_core::sc_ppq_base::left ( int  i  )  const [inline, protected]

sc_pq.h88 行で定義されています。

00089         { return i << 1; }

int sc_core::sc_ppq_base::right ( int  i  )  const [inline, protected]

sc_pq.h91 行で定義されています。

00092         { return (i << 1) + 1; }

void sc_core::sc_ppq_base::heapify ( int  i  )  [protected]

sc_pq.cpp106 行で定義されています。

00107 {
00108     int l;
00109     while( l = left( i ), l <= m_heap_size ) {
00110         int largest = (m_compar( m_heap[l], m_heap[i] ) > 0) ? l : i;
00111 
00112         int r = right( i );
00113         if( (r <= m_heap_size) &&
00114             (m_compar( m_heap[r], m_heap[largest] ) > 0) ) {
00115             largest = r;
00116         }
00117 
00118         if( largest != i ) {
00119             void* tmp = m_heap[i];
00120             m_heap[i] = m_heap[largest];
00121             m_heap[largest] = tmp;
00122             i = largest;
00123         } else {
00124             break;
00125         }
00126     }
00127 }


変数

void** sc_core::sc_ppq_base::m_heap [private]

sc_pq.h98 行で定義されています。

sc_pq.h99 行で定義されています。

sc_pq.h100 行で定義されています。

sc_pq.h101 行で定義されています。


このクラスの説明は次のファイルから生成されました:

SystemCに対してFri Jun 6 20:12:23 2008に生成されました。  doxygen 1.5.6