Revision d99e397d som/ChunkIDSet/chunkids_ops.c

View differences:

som/ChunkIDSet/chunkids_ops.c
109 109
  return -1;
110 110
}
111 111

  
112
int chunkID_set_get_earliest(const struct chunkID_set *h)
113
{
114
  int i, min;
115

  
116
  min = INT_MAX;
117
  for (i = 0; i < h->n_elements; i++) {
118
    min = (h->elements[i] < min) ? h->elements[i] : min;
119
  }
120

  
121
  return min;
122
}
123

  
124
int chunkID_set_get_latest(const struct chunkID_set *h)
125
{
126
  int i, max;
127

  
128
  max = INT_MIN;
129
  for (i = 0; i < h->n_elements; i++) {
130
    max = (h->elements[i] > max) ? h->elements[i] : max;
131
  }
132

  
133
  return max;
134
}
135

  
136
int chunkID_set_union(struct chunkID_set *h, struct chunkID_set *a)
137
{
138
  int i;
139

  
140
  for (i = 0; i < a->n_elements; i++) {
141
    int ret = chunkID_set_add_chunk(h,a->elements[i]);
142
    if (ret < 0) return ret;
143
  }
144
  return h->n_elements;
145
}
146

  
147 112
void chunkID_set_clear(struct chunkID_set *h, int size)
148 113
{
149 114
  h->n_elements = 0;

Also available in: Unified diff