📄 dllist.hp
字号:
// This may look like C code, but it is really -*- C++ -*-// WARNING: This file is obsolete. Use ../DLList.h, if you can./* Copyright (C) 1988 Free Software Foundation written by Doug Lea (dl@rocky.oswego.edu)This file is part of the GNU C++ Library. This library is freesoftware; you can redistribute it and/or modify it under the terms ofthe GNU Library General Public License as published by the FreeSoftware Foundation; either version 2 of the License, or (at youroption) any later version. This library is distributed in the hopethat it will be useful, but WITHOUT ANY WARRANTY; without even theimplied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULARPURPOSE. See the GNU Library General Public License for more details.You should have received a copy of the GNU Library General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, 675 Mass Ave, Cambridge, MA 02139, USA.*/#ifndef _<T>DLList_h#ifdef __GNUG__#pragma interface#endif#define _<T>DLList_h 1#include <Pix.h>#include "<T>.defs.h"#ifndef _<T>DLListNode_h#define _<T>DLListNode_h 1struct <T>DLListNode{ <T>DLListNode* bk; <T>DLListNode* fd; <T> hd; <T>DLListNode(); <T>DLListNode(const <T&> h, <T>DLListNode* p = 0, <T>DLListNode* n = 0); ~<T>DLListNode();};inline <T>DLListNode::<T>DLListNode() {}inline <T>DLListNode::<T>DLListNode(const <T&> h, <T>DLListNode* p, <T>DLListNode* n) :hd(h), bk(p), fd(n) {}inline <T>DLListNode::~<T>DLListNode() {}typedef <T>DLListNode* <T>DLListNodePtr;#endifclass <T>DLList{ friend class <T>DLListTrav; <T>DLListNode* h;public: <T>DLList(); <T>DLList(const <T>DLList& a); ~<T>DLList(); <T>DLList& operator = (const <T>DLList& a); int empty(); int length(); void clear(); Pix prepend(<T&> item); Pix append(<T&> item); void join(<T>DLList&); <T>& front(); <T> remove_front(); void del_front(); <T>& rear(); <T> remove_rear(); void del_rear(); <T>& operator () (Pix p); Pix first(); Pix last(); void next(Pix& p); void prev(Pix& p); int owns(Pix p); Pix ins_after(Pix p, <T&> item); Pix ins_before(Pix p, <T&> item); void del(Pix& p, int dir = 1); void del_after(Pix& p); void error(const char* msg); int OK();};inline <T>DLList::~<T>DLList(){ clear();}inline <T>DLList::<T>DLList(){ h = 0;}inline int <T>DLList::empty(){ return h == 0;}inline void <T>DLList::next(Pix& p){ p = (p == 0 || p == h->bk)? 0 : Pix(((<T>DLListNode*)p)->fd);}inline void <T>DLList::prev(Pix& p){ p = (p == 0 || p == h)? 0 : Pix(((<T>DLListNode*)p)->bk);}inline Pix <T>DLList::first(){ return Pix(h);}inline Pix <T>DLList::last(){ return (h == 0)? 0 : Pix(h->bk);}inline <T>& <T>DLList::operator () (Pix p){ if (p == 0) error("null Pix"); return ((<T>DLListNode*)p)->hd;}inline <T>& <T>DLList::front(){ if (h == 0) error("front: empty list"); return h->hd;}inline <T>& <T>DLList::rear(){ if (h == 0) error("rear: empty list"); return h->bk->hd;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -