~ubuntu-branches/ubuntu/raring/luatex/raring

« back to all changes in this revision

Viewing changes to source/libs/poppler/poppler-0.12.4/goo/GooList.h

  • Committer: Package Import Robot
  • Author(s): Norbert Preining
  • Date: 2011-05-20 09:40:39 UTC
  • mfrom: (0.8.1) (1.8.1) (19.2.3 oneiric)
  • Revision ID: package-import@ubuntu.com-20110520094039-7sezr4kqonjqxqz6
Tags: 0.70.1-1
* new upstream release (probably) matching TeX Live 2011
* deactivate fix-luatex-build-with-old-libpng patch, included upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//========================================================================
 
2
//
 
3
// GooList.h
 
4
//
 
5
// Copyright 2001-2003 Glyph & Cog, LLC
 
6
//
 
7
//========================================================================
 
8
 
 
9
#ifndef GLIST_H
 
10
#define GLIST_H
 
11
 
 
12
#ifdef USE_GCC_PRAGMAS
 
13
#pragma interface
 
14
#endif
 
15
 
 
16
#include "gtypes.h"
 
17
 
 
18
//------------------------------------------------------------------------
 
19
// GooList
 
20
//------------------------------------------------------------------------
 
21
 
 
22
class GooList {
 
23
public:
 
24
 
 
25
  // Create an empty list.
 
26
  GooList();
 
27
 
 
28
  // Create an empty list with space for <size1> elements.
 
29
  GooList(int sizeA);
 
30
 
 
31
  // Destructor - does not free pointed-to objects.
 
32
  ~GooList();
 
33
 
 
34
  //----- general
 
35
 
 
36
  // Get the number of elements.
 
37
  int getLength() { return length; }
 
38
 
 
39
  //----- ordered list support
 
40
 
 
41
  // Return the <i>th element.
 
42
  // Assumes 0 <= i < length.
 
43
  void *get(int i) { return data[i]; }
 
44
 
 
45
  // Append an element to the end of the list.
 
46
  void append(void *p);
 
47
 
 
48
  // Append another list to the end of this one.
 
49
  void append(GooList *list);
 
50
 
 
51
  // Insert an element at index <i>.
 
52
  // Assumes 0 <= i <= length.
 
53
  void insert(int i, void *p);
 
54
 
 
55
  // Deletes and returns the element at index <i>.
 
56
  // Assumes 0 <= i < length.
 
57
  void *del(int i);
 
58
 
 
59
  // Sort the list accoring to the given comparison function.
 
60
  // NB: this sorts an array of pointers, so the pointer args need to
 
61
  // be double-dereferenced.
 
62
  void sort(int (*cmp)(const void *ptr1, const void *ptr2));
 
63
 
 
64
  //----- control
 
65
 
 
66
  // Set allocation increment to <inc>.  If inc > 0, that many
 
67
  // elements will be allocated every time the list is expanded.
 
68
  // If inc <= 0, the list will be doubled in size.
 
69
  void setAllocIncr(int incA) { inc = incA; }
 
70
 
 
71
private:
 
72
 
 
73
  void expand();
 
74
  void shrink();
 
75
 
 
76
  void **data;                  // the list elements
 
77
  int size;                     // size of data array
 
78
  int length;                   // number of elements on list
 
79
  int inc;                      // allocation increment
 
80
};
 
81
 
 
82
#define deleteGooList(list, T)                        \
 
83
  do {                                              \
 
84
    GooList *_list = (list);                          \
 
85
    {                                               \
 
86
      int _i;                                       \
 
87
      for (_i = 0; _i < _list->getLength(); ++_i) { \
 
88
        delete (T*)_list->get(_i);                  \
 
89
      }                                             \
 
90
      delete _list;                                 \
 
91
    }                                               \
 
92
  } while (0)
 
93
 
 
94
#endif