📄 sllist.hp
字号:
// This may look like C code, but it is really -*- C++ -*-// WARNING: This file is obsolete. Use ../SLList.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>SLList_h#ifdef __GNUG__#pragma interface#endif#define _<T>SLList_h 1#include <Pix.h>#include "<T>.defs.h"#ifndef _<T>SLListNode_h#define _<T>SLListNode_h 1struct <T>SLListNode{ <T>SLListNode* tl; <T> hd; <T>SLListNode() { } <T>SLListNode(const <T&> h, <T>SLListNode* t = 0); ~<T>SLListNode() { }};inline <T>SLListNode::<T>SLListNode(const <T&> h, <T>SLListNode* t):hd(h), tl(t) {}typedef <T>SLListNode* <T>SLListNodePtr;#endifclass <T>SLList{protected: <T>SLListNode* last;public: <T>SLList(); <T>SLList(const <T>SLList& a); ~<T>SLList(); <T>SLList& operator = (const <T>SLList& a); int empty(); int length(); void clear(); Pix prepend(<T&> item); Pix append(<T&> item); void join(<T>SLList&); Pix prepend(<T>SLListNode*); Pix append(<T>SLListNode*); <T>& operator () (Pix p); Pix first(); void next(Pix& p); int owns(Pix p); Pix ins_after(Pix p, <T&> item); void del_after(Pix p); <T>& front(); <T>& rear(); <T> remove_front(); int remove_front(<T>& x); void del_front(); void error(const char* msg); int OK();};inline <T>SLList::~<T>SLList(){ clear();}inline <T>SLList::<T>SLList(){ last = 0;}inline int <T>SLList::empty(){ return last == 0;}inline Pix <T>SLList::first(){ return (last == 0)? 0 : Pix(last->tl);}inline void <T>SLList::next(Pix& p){ p = (p == 0 || p == last)? 0 : Pix(((<T>SLListNode*)(p))->tl);}inline <T>& <T>SLList::operator () (Pix p){ if (p == 0) error("null Pix"); return ((<T>SLListNode*)(p))->hd;}inline <T>& <T>SLList::front(){ if (last == 0) error("front: empty list"); return last->tl->hd;}inline <T>& <T>SLList::rear(){ if (last == 0) error("rear: empty list"); return last->hd;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -