-(*\r
- * beware IRC services, blinklist.pas\r
- * Copyright (C) 2002 Bas Steendijk\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *)\r
-unit blinklist;\r
-{$ifdef fpc}\r
- {$mode delphi}\r
-{$endif}\r
-\r
-\r
-interface\r
-\r
-type\r
- tlinklist=class(tobject)\r
- next:tlinklist;\r
- prev:tlinklist;\r
- constructor create;\r
- destructor destroy; override;\r
- end;\r
-\r
- {linklist with 2 links}\r
- tlinklist2=class(tlinklist)\r
- next2:tlinklist2;\r
- prev2:tlinklist2;\r
- end;\r
-\r
- {linklist with one pointer}\r
- tplinklist=class(tlinklist)\r
- p:pointer\r
- end;\r
-\r
- tstringlinklist=class(tlinklist)\r
- s:string;\r
- end;\r
-\r
- tthing=class(tlinklist)\r
- name:string; {name/nick}\r
- hashname:integer; {hash of name}\r
- end;\r
-\r
-{\r
-adding new block to list (baseptr)\r
-}\r
-procedure linklistadd(var baseptr:tlinklist;newptr:tlinklist);\r
-procedure linklistdel(var baseptr:tlinklist;item:tlinklist);\r
-\r
-\r
-procedure linklist2add(var baseptr,newptr:tlinklist2);\r
-procedure linklist2del(var baseptr:tlinklist2;item:tlinklist2);\r
-\r
-var\r
- linklistdebug:integer;\r
-\r
-implementation\r
-\r
-procedure linklistadd(var baseptr:tlinklist;newptr:tlinklist);\r
-var\r
- p:tlinklist;\r
-begin\r
- p := baseptr;\r
- baseptr := newptr;\r
- baseptr.prev := nil;\r
- baseptr.next := p;\r
- if p <> nil then p.prev := baseptr;\r
-end;\r
-\r
-procedure linklistdel(var baseptr:tlinklist;item:tlinklist);\r
-begin\r
- if item = baseptr then baseptr := item.next;\r
- if item.prev <> nil then item.prev.next := item.next;\r
- if item.next <> nil then item.next.prev := item.prev;\r
-end;\r
-\r
-procedure linklist2add(var baseptr,newptr:tlinklist2);\r
-var\r
- p:tlinklist2;\r
-begin\r
- p := baseptr;\r
- baseptr := newptr;\r
- baseptr.prev2 := nil;\r
- baseptr.next2 := p;\r
- if p <> nil then p.prev2 := baseptr;\r
-end;\r
-\r
-procedure linklist2del(var baseptr:tlinklist2;item:tlinklist2);\r
-begin\r
- if item = baseptr then baseptr := item.next2;\r
- if item.prev2 <> nil then item.prev2.next2 := item.next2;\r
- if item.next2 <> nil then item.next2.prev2 := item.prev2;\r
-end;\r
-\r
-constructor tlinklist.create;\r
-begin\r
- inherited create;\r
- inc(linklistdebug);\r
-end;\r
-\r
-destructor tlinklist.destroy;\r
-begin\r
- dec(linklistdebug);\r
- inherited destroy;\r
-end;\r
-\r
-end.\r