Changeset 494 for abuse/trunk/src/imlib/linked.h
- Timestamp:
- Apr 17, 2011, 11:56:44 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/imlib/linked.h
r481 r494 2 2 * Abuse - dark 2D side-scrolling platform game 3 3 * Copyright (c) 1995 Crack dot Com 4 * Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net> 4 5 * 5 6 * This software was released into the Public Domain. As with most public … … 15 16 // example compare function 16 17 // virtual int compare(void *n1, int field) 17 // { return ((classname *) n1)->data > data);}18 // { return ((classname *) n1)->data > data); } 18 19 // should return (1 if n1 is greater than (self)) else return 0 19 20 // field is the value determined by linked_list::set_sort_field … … 48 49 if (first) \ 49 50 for (controll=(type *)(first); \ 50 (!x || (controll)!=(type *)(first)); \51 (!x || (controll)!=(type *)(first)); \ 51 52 controll=(type *)(controll->next()),x++) 52 53 53 54 #define loop_forct(type,controll,first,cond,x) int x=0; if (first) for \ 54 (controll=(type *)(first); cond && (!x || controll!=(type *)(first));\55 (controll=(type *)(first); cond && (!x || controll!=(type *)(first)); \ 55 56 controll=(type *)(controll->next()),x++) 56 57 … … 59 60 class linked_node *nextp, *lastp; 60 61 public: 61 virtual int compare(void *n1, int field) { return(0);} // default is = (equal)62 class linked_node *next() { return nextp;}63 class linked_node *last() { return lastp;}64 void set_next(class linked_node *p) { nextp=p;}65 void set_last(class linked_node *p) { lastp=p;}62 virtual int compare(void *n1, int field) { return(0); } // default is = (equal) 63 class linked_node *next() { return nextp; } 64 class linked_node *last() { return lastp; } 65 void set_next(class linked_node *p) { nextp=p; } 66 void set_last(class linked_node *p) { lastp=p; } 66 67 virtual ~linked_node() { ; } 67 68 linked_node() { nextp=NULL; lastp=NULL; } … … 90 91 void add_end(class linked_node *p); 91 92 void insert(class linked_node *p); 92 void set_sort_field(int x) { sortby=x;} // this is passed to compare93 class linked_node *current() { return cn;}94 class linked_node *first() { return fn;}95 class linked_node *last() { return fn->last();}93 void set_sort_field(int x) { sortby=x; } // this is passed to compare 94 class linked_node *current() { return cn; } 95 class linked_node *first() { return fn; } 96 class linked_node *last() { return fn->last(); } 96 97 class linked_node *get_node(int x); 97 void set_current(class linked_node *p) { cn=p;}98 void go_first() { cn=fn;}99 void go_end() { cn=fn->last();}100 void go_next() { cn=cn->next();}101 void go_last() { cn=cn->last();}102 int number_nodes() { return nn;}98 void set_current(class linked_node *p) { cn=p; } 99 void go_first() { cn=fn; } 100 void go_end() { cn=fn->last(); } 101 void go_next() { cn=cn->next(); } 102 void go_last() { cn=cn->last(); } 103 int number_nodes() { return nn; } 103 104 int node_number(linked_node *p); 104 105 int unlink(linked_node *p);
Note: See TracChangeset
for help on using the changeset viewer.