中国开发网: 论坛: 程序员情感CBD: 贴子 497353
beijingshizi: 是ACE的文件。不是我写的。如下
ACE_RCSID(ace, Unbounded_Set, "Unbounded_Set.cpp,v 4.11 2003/07/27 20:48:28 dhinton Exp")

ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Set)

template <class T> size_t
ACE_Unbounded_Set<T>::size (void) const
{
// ACE_TRACE ("ACE_Unbounded_Set<T>::size");
return this->cur_size_;
}

template <class T> int
ACE_Unbounded_Set<T>::insert_tail (const T &item)
{
// ACE_TRACE ("ACE_Unbounded_Set<T>::insert_tail");
ACE_Node<T> *temp;

// Insert <item> into the old dummy node location.
this->head_->item_ = item;

// Create a new dummy node.
ACE_NEW_MALLOC_RETURN (temp,
ACE_static_cast(ACE_Node<T>*,
this->allocator_->malloc (sizeof (ACE_Node<T>))),
:107
template <class T> void
ACE_Unbounded_Set<T>::copy_nodes (const ACE_Unbounded_Set<T> &us)
{
for (ACE_Node<T> *curr = us.head_->next_;
curr != us.head_;
curr = curr->next_)
this->insert_tail (curr->item_);
}

template <class T> void
ACE_Unbounded_Set<T>::delete_nodes (void)
{
ACE_Node<T> *curr = this->head_->next_;

// Keep looking until we've hit the dummy node.

while (curr != this->head_)
{
ACE_Node<T> *temp = curr;
curr = curr->next_;

//这里是指出错误的地方
ACE_DES_FREE_TEMPLATE (temp,
this->allocator_->free,
ACE_Node,
<T>);
this->cur_size_--;
}

// Reset the list to be a circular list with just a dummy node.
this->head_->next_ = this->head_;
}

template <class T>
ACE_Unbounded_Set<T>::~ACE_Unbounded_Set (void)
{
// ACE_TRACE ("ACE_Unbounded_Set<T>::~ACE_Unbounded_Set");

this->delete_nodes ();

// Delete the dummy node.
ACE_DES_FREE_TEMPLATE (head_,
this->allocator_->free,

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录