Ignore:
Timestamp:
Apr 22, 2011, 7:32:17 PM (11 years ago)
Author:
Sam Hocevar
Message:

imlib: remove a lot of dead code, especially from the linked list and
the WAV reader.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/imlib/linked.h

    r519 r534  
    1111// linked.h  - linked list and linked list node classes
    1212// written June 2, 1992 by Jonathan Clark  (at home)
    13 // these classes provide the basic groundwork for any future linked list
    14 // please derive your own linked_node subclass and define the virtual
    15 // function compare.
    16 // example compare function
    17 //   virtual int compare(void *n1, int field)
    18 //        { return ((classname *) n1)->data > data); }
    19 //  should return (1 if n1 is greater than (self)) else return 0
    20 //  field is the value determined by linked_list::set_sort_field
    21 //  this defaults to 1
    2213
     14#ifndef __LINKED_H__
     15#define __LINKED_H__
    2316
    24 #ifndef linkman
    25 #define linkman
    2617#include <stdio.h>
    2718#include <stdlib.h>
    2819#include <string.h>
    2920
    30 #define loop(controll,first,inside) { controll=first; \
    31   if (first) do { inside controll=controll->next(); } \
    32   while (controll!=first); }
    33 
    34 #define loopt(type,controll,first,inside) { controll=(type *)(first); \
    35   if (first) do { inside controll=(type *)(controll->next()); } \
    36   while (controll!=(type *)(first)); }
    37 
    38 
    39 #define loop_rev(controll,last,inside) { controll=last; \
    40   if (first) do { inside controll=controll->last(); } \
    41   while (controll!=last); }
    42 
    43 #define loopct(type,controll,first,cond,inside) { controll=(type *)first; \
    44   if (first && (cond)) do { inside controll=(type *)controll->next(); } \
    45   while (controll!=(type *)first && (cond)); }
    46 
    47 #define loop_fort(type,controll,first,x) \
    48   int x=0; \
    49   if (first) \
    50      for (controll=(type *)(first); \
    51           (!x || (controll)!=(type *)(first)); \
    52           controll=(type *)(controll->next()),x++)
    53 
    54 #define loop_forct(type,controll,first,cond,x) int x=0; if (first) for \
    55   (controll=(type *)(first); cond && (!x || controll!=(type *)(first)); \
    56   controll=(type *)(controll->next()),x++)
    57 
    5821class linked_node
    5922{
    60   class linked_node *nextp, *lastp;
     23    friend class linked_list;
     24
    6125public:
    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; }
    67   virtual ~linked_node() { ; }
    68   linked_node() { nextp=NULL; lastp=NULL; }
     26    linked_node() { m_next = m_prev = NULL; }
     27    virtual ~linked_node() { ; }
     28
     29    inline class linked_node *Next() { return m_next; }
     30    inline class linked_node *Prev() { return m_prev; }
     31    inline void SetNext(class linked_node *p) { m_next = p; }
     32    inline void SetPrev(class linked_node *p) { m_prev = p; }
     33
     34private:
     35    class linked_node *m_next, *m_prev;
    6936};
    7037
     
    8350class linked_list
    8451{
    85   class linked_node *fn, *cn;     // first and current nodes
    86   int nn; char sortby;
    87 public :
    88   linked_list(linked_node *first=NULL);
    89   void add_front(class linked_node *p);
    90   void add_end(class linked_node *p);
    91   void insert(class linked_node *p);
    92   void set_sort_field(int x) { sortby=x; }   // this is passed to compare
    93   class linked_node *current() { return cn; }
    94   class linked_node *first() { return fn; }
    95   class linked_node *last() { return fn->last(); }
    96   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; }
    103   int node_number(linked_node *p);
    104   int unlink(linked_node *p);
    105   ~linked_list();
     52public:
     53    linked_list();
     54    ~linked_list();
     55
     56    void add_front(class linked_node *p);
     57    void add_end(class linked_node *p);
     58    int unlink(linked_node *p);
     59
     60    inline class linked_node *first() { return m_first; }
     61    inline class linked_node *prev() { return m_first->Prev(); }
     62    inline size_t Count() { return m_count; }
     63
     64private:
     65    linked_node *m_first;
     66    size_t m_count;
    10667};
    10768
    10869#endif
    10970
    110 
    111 
Note: See TracChangeset for help on using the changeset viewer.