| - -( dyne // software :: culture :: events :: tazebao :: discussion :: museum \\ freaknet )- - |
00001 /* Fast atomical linklist class 00002 * (c) Copyright 2001 Denis Roio aka jaromil <jaromil@dyne.org> 00003 * 00004 * This source code is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Public License as published 00006 * by the Free Software Foundation; either version 2 of the License, 00007 * or (at your option) any later version. 00008 * 00009 * This source code is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 * Please refer to the GNU Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Public License along with 00015 * this source code; if not, write to: 00016 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __linklist_h__ 00020 #define __linklist_h__ 00021 00022 #include <pthread.h> 00023 00024 class Entry; 00025 00026 class Linklist { 00027 public: 00028 Linklist(); 00029 virtual ~Linklist(); 00030 00031 Entry *begin() { return(first); }; 00032 Entry *end() { return(last); }; 00033 int len() { return(length); }; 00034 00035 void append(Entry *addr); 00036 void add(Entry *addr) { append(addr); }; /* lazy backward compatibility */ 00037 void prepend(Entry *addr); 00038 void insert(Entry *addr, int pos); 00039 00040 bool rem(int pos); 00041 bool sel(int pos); 00042 bool clear(); 00043 bool moveup(int pos); 00044 bool movedown(int pos); 00045 bool moveto(int num, int pos); 00046 Entry *pick(int pos); 00047 Entry *Linklist::selected(); 00048 00049 Entry *operator[](int pos) { return pick(pos); }; 00050 00051 /* don't touch these directly */ 00052 Entry *first; 00053 Entry *last; 00054 int length; 00055 00056 /* deprecated, here just for MuSE */ 00057 Entry *pick_id(int id); 00058 int selected_pos(); 00059 00060 /* thread stuff */ 00061 void lock(); 00062 void unlock(); 00063 private: 00064 pthread_mutex_t _mutex; 00065 00066 }; 00067 00068 class Entry { 00069 public: 00070 Entry(); 00071 Entry(void *value); 00072 ~Entry(); 00073 00074 Entry *next; 00075 Entry *prev; 00076 00077 Linklist *list; 00078 00079 bool up(); 00080 bool down(); 00081 bool move(int pos); 00082 void rem(); 00083 void sel(bool on); 00084 void *get_value(); 00085 void set_value(void *val); 00086 00087 int id; /* deprecated, here just for MuSE */ 00088 bool select; 00089 private: 00090 void *value; 00091 }; 00092 00093 #endif
|
|
|
|
| Copyleft 2000 - 2008 dyne.org foundation and respective authors. Verbatim copying and distribution is permitted in any medium, provided this notice is preserved. Send inquiries & questions to dyne.org's hackers. |
|