~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/discrete_interval.h

  • Committer: Brian Aker
  • Date: 2009-02-12 22:45:08 UTC
  • Revision ID: brian@tangent.org-20090212224508-mrd9jwgn1zjdpqdk
Minor refactoring (we will need to disconnect the code from the include
file).

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
    return tmp;
145
145
  }
146
146
  ~Discrete_intervals_list() { empty(); };
147
 
  bool append(uint64_t start, uint64_t val, uint64_t incr);
148
 
  bool append(Discrete_interval *interval);
149
147
  uint64_t minimum()     const { return (head ? head->minimum() : 0); };
150
148
  uint64_t maximum()     const { return (head ? tail->maximum() : 0); };
151
149
  uint32_t      nb_elements() const { return elements; }
 
150
 
 
151
  bool append(uint64_t start, uint64_t val, uint64_t incr)
 
152
  {
 
153
    /* first, see if this can be merged with previous */
 
154
    if ((head == NULL) || tail->merge_if_contiguous(start, val, incr))
 
155
    {
 
156
      /* it cannot, so need to add a new interval */
 
157
      Discrete_interval *new_interval= new Discrete_interval(start, val, incr);
 
158
      return(append(new_interval));
 
159
    }
 
160
    return(0);
 
161
  }
 
162
 
 
163
  bool append(Discrete_interval *new_interval)
 
164
  {
 
165
    if (unlikely(new_interval == NULL))
 
166
      return(1);
 
167
    if (head == NULL)
 
168
      head= current= new_interval;
 
169
    else
 
170
      tail->next= new_interval;
 
171
    tail= new_interval;
 
172
    elements++;
 
173
    return(0);
 
174
  }
 
175
 
152
176
};
153
177
 
154
178
#endif /* DRIZZLED_DISCRETE_INTERVALS_H */