⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list.cc

📁 [Game.Programming].Academic - Graphics Gems (6 books source code)
💻 CC
字号:
// -*- C++ -*-//// list.cc// by George Vanecek, 1994// This List template is used frequently, and consequently, we// want to improve its performance.  Since memory allocation and// dealocation is very time consuming, we keep a stack of free ListNodes,// and reuse them.#include "list.h"ListNode* ListNode::freeList = NULL;// Allocate ListNode first from our free list, then from system heap.void* ListNode::operator new( size_t s ){  if( freeList ) {    ListNode* const n = freeList;    freeList = freeList->nxt;    return n;  }  return ::operator new(s);}// Delete node by placing it on our free list.void ListNode::operator delete( void* p ){  ListNode* const n = (ListNode*)p;  n->nxt   = freeList;  freeList = n;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -