gwenhywfar  4.99.25rc9
idlist64.c
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Mon Mar 01 2004
3  copyright : (C) 2018 by Martin Preuss
4  email : martin@libchipcard.de
5 
6  ***************************************************************************
7  * *
8  * This library is free software; you can redistribute it and/or *
9  * modify it under the terms of the GNU Lesser General Public *
10  * License as published by the Free Software Foundation; either *
11  * version 2.1 of the License, or (at your option) any later version. *
12  * *
13  * This library is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16  * Lesser General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU Lesser General Public *
19  * License along with this library; if not, write to the Free Software *
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21  * MA 02111-1307 USA *
22  * *
23  ***************************************************************************/
24 
25 
26 
27 #ifdef HAVE_CONFIG_H
28 # include <config.h>
29 #endif
30 
31 #define DISABLE_DEBUGLOG
32 
33 #include "idlist64_p.h"
34 #include <gwenhywfar/debug.h>
35 
36 
37 #include <stdlib.h>
38 #include <assert.h>
39 #include <string.h>
40 
41 /* Uncomment this to use the old compact mode of entry storage
42  * compact means that empty entries within tables are filled from begin on when
43  * adding new entries (this was the old mode of id allocation).
44  * The new mode is to add entries to the last table. If the last table is full
45  * a new table is created and the new id added to that table.
46  */
47 /*#define GWEN_IDLIST64_COMPACT */
48 
49 
50 GWEN_IDTABLE64 *GWEN_IdTable64_new(void)
51 {
52  GWEN_IDTABLE64 *idt;
53 
54  GWEN_NEW_OBJECT(GWEN_IDTABLE64, idt);
55  idt->refCount=1;
56 
57  idt->freeEntries=GWEN_IDTABLE64_MAXENTRIES;
58  return idt;
59 }
60 
61 
62 
63 void GWEN_IdTable64_free(GWEN_IDTABLE64 *idt)
64 {
65  if (idt) {
66  assert(idt->refCount);
67  if (--(idt->refCount)==0) {
68  GWEN_FREE_OBJECT(idt);
69  }
70  }
71 }
72 
73 
74 
75 #if 0
76 void GWEN_IdTable64_Attach(GWEN_IDTABLE64 *idt)
77 {
78  assert(idt);
79  assert(idt->refCount);
80  idt->refCount++;
81 }
82 #endif
83 
84 
85 
86 static inline int GWEN_IdTable64_AddId(GWEN_IDTABLE64 *idt, uint64_t id)
87 {
88  unsigned int i;
89 
90  for (i=0; i<GWEN_IDTABLE64_MAXENTRIES; i++) {
91  if (idt->entries[i]==0) {
92  idt->entries[i]=id;
93  idt->freeEntries--;
94  return 0;
95  }
96  } /* for */
97  return -1;
98 }
99 
100 
101 
102 static inline int GWEN_IdTable64_AppendId(GWEN_IDTABLE64 *idt, uint64_t id)
103 {
104  if (idt->freeEntries) {
105  unsigned int i;
106 
107  i=GWEN_IDTABLE64_MAXENTRIES-idt->freeEntries;
108  idt->entries[i]=id;
109  idt->freeEntries--;
110  return 0;
111  }
112  else
113  return -1;
114 }
115 
116 
117 
118 static inline int GWEN_IdTable64_HasId(const GWEN_IDTABLE64 *idt, uint64_t id)
119 {
120  unsigned int i;
121 
122  for (i=0; i<GWEN_IDTABLE64_MAXENTRIES; i++) {
123  if (idt->entries[i]==id) {
124  return 1;
125  }
126  } /* for */
127  return 0;
128 }
129 
130 
131 
132 static inline int GWEN_IdTable64_DelId(GWEN_IDTABLE64 *idt, uint64_t id)
133 {
134  unsigned int i;
135 
136  for (i=0; i<GWEN_IDTABLE64_MAXENTRIES; i++) {
137  if (idt->entries[i]==id) {
138  idt->entries[i]=0;
139  idt->freeEntries++;
140  return 0;
141  }
142  } /* for */
143  return -1;
144 }
145 
146 
147 
148 static inline int GWEN_IdTable64_IsEmpty(const GWEN_IDTABLE64 *idt)
149 {
150  return GWEN_IDTABLE64_MAXENTRIES==idt->freeEntries;
151 }
152 
153 
154 
155 static inline int GWEN_IdTable64_IsFull(const GWEN_IDTABLE64 *idt)
156 {
157  return idt->freeEntries==0;
158 }
159 
160 
161 #if 0
162 static inline unsigned int GWEN_IdTable64_GetCount(const GWEN_IDTABLE64 *idt)
163 {
164  return GWEN_IDTABLE64_MAXENTRIES-idt->freeEntries;
165 }
166 
167 
168 
169 static inline uint64_t GWEN_IdTable64_GetFirstId(GWEN_IDTABLE64 *idt)
170 {
171  unsigned int i;
172 
173  assert(idt);
174  idt->current=0;
175  for (i=0; i<GWEN_IDTABLE64_MAXENTRIES; i++) {
176  if (idt->entries[i]!=0) {
177  idt->current=i;
178  return idt->entries[i];
179  }
180  } /* for */
181  return 0;
182 }
183 
184 
185 
186 static inline uint64_t GWEN_IdTable64_GetNextId(GWEN_IDTABLE64 *idt)
187 {
188  unsigned int i;
189 
190  for (i=idt->current+1; i<GWEN_IDTABLE64_MAXENTRIES; i++) {
191  if (idt->entries[i]!=0) {
192  idt->current=i;
193  return idt->entries[i];
194  }
195  } /* for */
196  idt->current=GWEN_IDTABLE64_MAXENTRIES;
197  return 0;
198 }
199 
200 
201 
202 static inline uint64_t GWEN_IdTable64_GetFirstId2(const GWEN_IDTABLE64 *idt,
203  uint64_t *tabIdx)
204 {
205  unsigned int i;
206 
207  for (i=0; i<GWEN_IDTABLE64_MAXENTRIES; i++) {
208  if (idt->entries[i]!=0) {
209  *tabIdx=i;
210  return idt->entries[i];
211  }
212  } /* for */
213  return 0;
214 }
215 
216 
217 
218 static inline uint64_t GWEN_IdTable64_GetNextId2(const GWEN_IDTABLE64 *idt,
219  uint64_t *tabIdx)
220 {
221  unsigned int i;
222 
223  for (i=(*tabIdx)+1; i<GWEN_IDTABLE64_MAXENTRIES; i++) {
224  if (idt->entries[i]!=0) {
225  *tabIdx=i;
226  return idt->entries[i];
227  }
228  } /* for */
229  return 0;
230 }
231 #endif
232 
233 
234 
235 
236 
238 {
239  GWEN_IDLIST64 *idl;
240 
242  idl->refCount=1;
243  return idl;
244 }
245 
246 
247 
249 {
250  assert(idl);
251  assert(idl->refCount);
252  idl->refCount++;
253 }
254 
255 
256 
258 {
259  if (idl) {
260  assert(idl->refCount);
261  if (idl->refCount==1) {
262  GWEN_IdList64_Clear(idl);
263  idl->refCount=0;
264  GWEN_FREE_OBJECT(idl);
265  }
266  else
267  idl->refCount--;
268  }
269 }
270 
271 
272 
273 void GWEN_IdList64_AddTable(GWEN_IDLIST64 *idl, GWEN_IDTABLE64 *idt)
274 {
275  GWEN_IDTABLE64 **tablePtr;
276  uint32_t idx;
277 
278  assert(idl);
279 
280  tablePtr=idl->pIdTablePointers;
281  for (idx=0, tablePtr=idl->pIdTablePointers; idx<idl->idTableCount; idx++, tablePtr++) {
282  if (*tablePtr==NULL)
283  break;
284  } /* while */
285 
286  if (idx>=idl->idTableCount) {
287  uint32_t newCount;
288  GWEN_IDTABLE64 **newPtr;
289 
290  /* resize */
291  newCount=idl->idTableCount+GWEN_IDLIST64_STEP;
292  newPtr=(GWEN_IDTABLE64 **)realloc(idl->pIdTablePointers, sizeof(GWEN_IDTABLE64 *)*newCount);
293  assert(newPtr);
294  /* init new pointers */
295  memset((void *)(newPtr+idl->idTableCount),
296  0,
297  sizeof(GWEN_IDTABLE64 *)*(newCount-idl->idTableCount));
298  idl->pIdTablePointers=newPtr;
299  idl->pIdTablePointers[idl->idTableCount]=idt;
300  idl->lastTableIdx=idl->idTableCount; /* this is the idx of the new table, and it is the last one */
301  idl->idTableCount=newCount;
302  }
303  else {
304  idl->pIdTablePointers[idx]=idt;
305  idl->lastTableIdx=idx;
306  }
307 }
308 
309 
310 
311 int GWEN_IdList64_AddId(GWEN_IDLIST64 *idl, uint64_t id)
312 {
313 #ifdef GWEN_IDLIST64_COMPACT
314  GWEN_IDTABLE64 *idt=NULL;
315  GWEN_IDTABLE64 **tablePtr;
316  int idx;
317 
318  assert(idl);
319 
320  if (idl->pIdTablePointers==NULL) {
321  /* create an initial pointer table which can take up to GWEN_IDLIST64_STEP pointers */
322  idl->pIdTablePointers=(GWEN_IDTABLE64 **) malloc(sizeof(GWEN_IDTABLE64 *)*GWEN_IDLIST64_STEP);
323  assert(idl->pIdTablePointers);
324  memset(idl->pIdTablePointers, 0, sizeof(GWEN_IDTABLE64 *)*GWEN_IDLIST64_STEP);
325  idl->idTableCount=GWEN_IDLIST64_STEP;
326  }
327 
328  for (idx=0, tablePtr=idl->pIdTablePointers; idx<idl->idTableCount; idx++, tablePtr++) {
329  idt=*tablePtr;
330  if (idt && !GWEN_IdTable64_IsFull(idt))
331  break;
332  } /* while */
333 
334  if (idx>=idl->idTableCount) {
335  idt=GWEN_IdTable64_new();
336  GWEN_IdList64_AddTable(idl, idt);
337  }
338  GWEN_IdTable64_AddId(idt, id);
339  idl->entryCount++;
340  return 0;
341 #else
342  GWEN_IDTABLE64 *idt=NULL;
343  int idx;
344 
345  assert(idl);
346 
347  if (idl->pIdTablePointers==NULL) {
348  /* create an initial pointer table which can take up to GWEN_IDLIST64_STEP pointers */
349  idl->pIdTablePointers=(GWEN_IDTABLE64 **) malloc(sizeof(GWEN_IDTABLE64 *)*GWEN_IDLIST64_STEP);
350  assert(idl->pIdTablePointers);
351  memset(idl->pIdTablePointers, 0, sizeof(GWEN_IDTABLE64 *)*GWEN_IDLIST64_STEP);
352  idl->idTableCount=GWEN_IDLIST64_STEP;
353  }
354  idx=idl->lastTableIdx;
355  idt=idl->pIdTablePointers[idx];
356  if (idt==NULL || GWEN_IdTable64_IsFull(idt)) {
357  idt=GWEN_IdTable64_new();
358  GWEN_IdList64_AddTable(idl, idt);
359  }
360  GWEN_IdTable64_AddId(idt, id);
361  idl->entryCount++;
362  return 0;
363 #endif
364 }
365 
366 
367 
368 int GWEN_IdList64_DelId(GWEN_IDLIST64 *idl, uint64_t id)
369 {
370  if (idl->pIdTablePointers) {
371  GWEN_IDTABLE64 *idt=NULL;
372  GWEN_IDTABLE64 **tablePtr;
373  uint32_t idx;
374 
375  for (idx=0, tablePtr=idl->pIdTablePointers; idx<idl->idTableCount; idx++, tablePtr++) {
376  idt=*tablePtr;
377  if (idt && !GWEN_IdTable64_DelId(idt, id)) {
378  /* found a table which had this id */
379  GWEN_IdList64_Clean(idl);
380  idl->entryCount--;
381  return 0;
382  }
383  }
384  }
385 
386  return -1;
387 }
388 
389 
390 
391 int GWEN_IdList64_HasId(const GWEN_IDLIST64 *idl, uint64_t id)
392 {
393  if (idl->pIdTablePointers) {
394  GWEN_IDTABLE64 *idt=NULL;
395  GWEN_IDTABLE64 **tablePtr;
396  uint32_t idx;
397 
398  for (idx=0, tablePtr=idl->pIdTablePointers; idx<idl->idTableCount; idx++, tablePtr++) {
399  idt=*tablePtr;
400  if (idt && GWEN_IdTable64_HasId(idt, id))
401  return 1;
402  }
403  }
404 
405  return 0;
406 }
407 
408 
409 
411 {
412  GWEN_IDTABLE64 *idt=NULL;
413  GWEN_IDTABLE64 **tablePtr;
414  uint32_t idx;
415 
416  for (idx=0, tablePtr=idl->pIdTablePointers; idx<idl->idTableCount; idx++, tablePtr++) {
417  idt=*tablePtr;
418  if (idt && GWEN_IdTable64_IsEmpty(idt)) {
419  GWEN_IdTable64_free(idt);
420  *tablePtr=NULL;
421  }
422  }
423 }
424 
425 
426 
428 {
429  if (idl->pIdTablePointers) {
430  GWEN_IDTABLE64 *idt=NULL;
431  GWEN_IDTABLE64 **tablePtr;
432  uint32_t idx;
433 
434  for (idx=0, tablePtr=idl->pIdTablePointers; idx<idl->idTableCount; idx++, tablePtr++) {
435  idt=*tablePtr;
436  if (idt) {
437  GWEN_IdTable64_free(idt);
438  *tablePtr=NULL;
439  }
440  }
441  free(idl->pIdTablePointers);
442  idl->pIdTablePointers=NULL;
443  }
444  idl->entryCount=0;
445  idl->nextIdx=0;
446 }
447 
448 
449 
450 static int __compAscending(const void *pa, const void *pb)
451 {
452  uint64_t a=*((const uint64_t *)pa);
453  uint64_t b=*((const uint64_t *)pb);
454 
455  if (a<b)
456  return -1;
457  else if (a>b)
458  return 1;
459  else
460  return 0;
461 }
462 
463 
464 
465 static int __compDescending(const void *pa, const void *pb)
466 {
467  uint64_t a=*((const uint64_t *)pa);
468  uint64_t b=*((const uint64_t *)pb);
469 
470  if (a<b)
471  return 1;
472  else if (a>b)
473  return -1;
474  else
475  return 0;
476 }
477 
478 
479 
480 static int GWEN_IdList64__Sort(GWEN_IDLIST64 *idl, int ascending)
481 {
482  assert(idl);
483  assert(idl->refCount);
484  if (idl->pIdTablePointers && idl->entryCount) {
486  unsigned int cnt;
487  uint64_t *ptr;
488  unsigned int i;
489 
490  assert(idl);
491 
492  /* count ids */
493  cnt=idl->entryCount;
494 
495  /* move ids to a temporary list */
496  ptr=(uint64_t *)malloc(sizeof(uint64_t)*cnt);
497  assert(ptr);
498 
500  for (i=0; i<cnt; i++) {
501  uint64_t id;
502 
503  if (i==0)
505  else
507  assert(id);
508  ptr[i]=id;
509  } /* for */
511 
512  /* remove all tables (we will add sorted tables later) */
513  GWEN_IdList64_Clear(idl);
514 
515  if (ascending)
516  qsort(ptr, cnt, sizeof(uint64_t), __compAscending);
517  else
518  qsort(ptr, cnt, sizeof(uint64_t), __compDescending);
519 
520  /* move back sorted list of ids from temporary list */
521  for (i=0; i<cnt; i++) {
522  GWEN_IdList64_AddId(idl, ptr[i]);
523  }
524  free(ptr);
525  }
526  return 0;
527 }
528 
529 
530 
532 {
533  return GWEN_IdList64__Sort(idl, 1);
534 }
535 
536 
537 
539 {
540  return GWEN_IdList64__Sort(idl, 0);
541 }
542 
543 
544 
546 {
547  GWEN_IDLIST64 *nidl;
548  uint32_t idx;
549 
550  nidl=GWEN_IdList64_new();
551 
552  nidl->idTableCount=idl->idTableCount;
553  nidl->entryCount=idl->entryCount;
554  if (idl->pIdTablePointers) {
555  for (idx=0; idx<idl->idTableCount; idx++) {
556  GWEN_IDTABLE64 *idt;
557 
558  idt=idl->pIdTablePointers[idx];
559  if (idt && !GWEN_IdTable64_IsEmpty(idt)) {
560  GWEN_IDTABLE64 *nidt;
561 
562  nidt=GWEN_IdTable64_new();
563  memmove(nidt->entries, idt->entries, GWEN_IDTABLE64_MAXENTRIES*sizeof(uint64_t));
564  nidt->freeEntries=idt->freeEntries;
565  GWEN_IdList64_AddTable(nidl, nidt);
566  }
567  }
568  }
569 
570  return nidl;
571 }
572 
573 
574 
576 {
577  assert(idl);
578  assert(idl->refCount);
579 
580  return idl->entryCount;
581 }
582 
583 
584 
585 uint64_t GWEN_IdList64__GetFirstId(const GWEN_IDLIST64 *idl, uint64_t *pos)
586 {
587  GWEN_IDTABLE64 *idt=NULL;
588  GWEN_IDTABLE64 **tablePtr;
589  uint32_t idx;
590  int idIndex=0;
591 
592  *pos=0;
593  for (idx=0, tablePtr=idl->pIdTablePointers; idx<idl->idTableCount; idx++, tablePtr++) {
594  idt=*tablePtr;
595  if (idt && !GWEN_IdTable64_IsEmpty(idt)) {
596  int i;
597  uint64_t id;
598 
599  for (i=0; i<GWEN_IDTABLE64_MAXENTRIES; i++) {
600  if (idt->entries[i]!=0) {
601  id=idt->entries[i];
602  *pos=idIndex+i+1;
603  return id;
604  }
605  }
606  }
607  idIndex+=GWEN_IDTABLE64_MAXENTRIES;
608  }
609 
610  return 0;
611 }
612 
613 
614 
615 uint64_t GWEN_IdList64__GetNextId(const GWEN_IDLIST64 *idl, uint64_t *pos)
616 {
617  if (*pos) {
618  GWEN_IDTABLE64 *idt;
619  uint64_t tableNum=*pos / GWEN_IDTABLE64_MAXENTRIES;
620  uint64_t tableIdx=*pos % GWEN_IDTABLE64_MAXENTRIES;
621  GWEN_IDTABLE64 **tablePtr;
622  int idIndex=0;
623  uint32_t idx;
624 
625  if (tableNum>idl->idTableCount) {
626  DBG_ERROR(GWEN_LOGDOMAIN, "Table number out of range");
627  *pos=0;
628  return 0;
629  }
630 
631  idIndex=(tableNum*GWEN_IDTABLE64_MAXENTRIES);
632  for (idx=tableNum, tablePtr=idl->pIdTablePointers+tableNum; idx<idl->idTableCount; idx++, tablePtr++) {
633  idt=*tablePtr;
634  if (idt && !GWEN_IdTable64_IsEmpty(idt)) {
635  int i;
636  uint64_t id;
637 
638  if (idx==tableNum) {
639  for (i=tableIdx; i<GWEN_IDTABLE64_MAXENTRIES; i++) {
640  if (idt->entries[i]!=0) {
641  id=idt->entries[i];
642  *pos=idIndex+i+1;
643  return id;
644  }
645  }
646  }
647  else {
648  for (i=0; i<GWEN_IDTABLE64_MAXENTRIES; i++) {
649  if (idt->entries[i]!=0) {
650  id=idt->entries[i];
651  *pos=idIndex+i+1;
652  return id;
653  }
654  }
655  }
656  }
657  idIndex+=GWEN_IDTABLE64_MAXENTRIES;
658  }
659  *pos=0;
660  }
661 
662  return 0;
663 }
664 
665 
666 
667 #ifndef NO_DEPRECATED_SYMBOLS
669 {
670  return GWEN_IdList64__GetFirstId(idl, &(idl->nextIdx));
671 }
672 
673 
674 
676 {
677  return GWEN_IdList64__GetNextId(idl, &(idl->nextIdx));
678 }
679 
680 
681 
682 uint64_t GWEN_IdList64_GetFirstId2(const GWEN_IDLIST64 *idl, uint64_t *pos)
683 {
684  return GWEN_IdList64__GetFirstId(idl, pos);
685 }
686 
687 
688 
689 uint64_t GWEN_IdList64_GetNextId2(const GWEN_IDLIST64 *idl, uint64_t *pos)
690 {
691  return GWEN_IdList64__GetNextId(idl, pos);
692 }
693 #endif // ifndef NO_DEPRECATED_SYMBOLS
694 
695 
696 
697 
698 
699 
701 {
703 
704  assert(idl);
706 
708  it->list=idl;
709 
710  return it;
711 }
712 
713 
714 
716 {
717  if (it) {
718  GWEN_IdList64_free(it->list);
719  GWEN_FREE_OBJECT(it);
720  }
721 }
722 
723 
724 
726 {
727  return GWEN_IdList64__GetFirstId(it->list, &(it->nextIndex));
728 }
729 
730 
731 
733 {
734  return GWEN_IdList64__GetNextId(it->list, &(it->nextIndex));
735 }
736 
737 
738 
739 int GWEN_IdList64_AppendId(GWEN_IDLIST64 *idl, uint64_t id)
740 {
741  GWEN_IDTABLE64 *idt=NULL;
742 
743  assert(idl);
744 
745  if (idl->pIdTablePointers==NULL) {
746  /* create an initial pointer table which can take up to GWEN_IDLIST64_STEP pointers */
747  idl->pIdTablePointers=(GWEN_IDTABLE64 **) malloc(sizeof(GWEN_IDTABLE64 *)*GWEN_IDLIST64_STEP);
748  assert(idl->pIdTablePointers);
749  memset(idl->pIdTablePointers, 0, sizeof(GWEN_IDTABLE64 *)*GWEN_IDLIST64_STEP);
750  idl->idTableCount=GWEN_IDLIST64_STEP;
751  }
752 
753  assert(idl->lastTableIdx<idl->idTableCount);
754  idt=idl->pIdTablePointers[idl->lastTableIdx];
755  if (idt==NULL || GWEN_IdTable64_IsFull(idt)) {
756  idt=GWEN_IdTable64_new();
757  GWEN_IdList64_AddTable(idl, idt);
758  }
759 
760  GWEN_IdTable64_AppendId(idt, id);
761  idl->entryCount++;
762  return 0;
763 }
764 
765 
766 
767 uint64_t GWEN_IdList64_GetIdAt(const GWEN_IDLIST64 *idl, uint64_t idx)
768 {
769  GWEN_IDTABLE64 *idt;
770  uint64_t tableNum=idx / GWEN_IDTABLE64_MAXENTRIES;
771  uint64_t tableIdx=idx % GWEN_IDTABLE64_MAXENTRIES;
772 
773  assert(idl);
774  if (tableNum>idl->idTableCount) {
775  DBG_INFO(GWEN_LOGDOMAIN, "Table index out of range");
776  return 0;
777  }
778 
779  idt=idl->pIdTablePointers[tableNum];
780  if (idt==NULL) {
781  DBG_INFO(GWEN_LOGDOMAIN, "Table index points to an empty table");
782  return 0;
783  }
784 
785  return idt->entries[tableIdx];
786 }
787 
788 
789 
790 
791 
792 
793 
794 
795 
796 
797 
uint64_t GWEN_IdList64_GetFirstId2(const GWEN_IDLIST64 *idl, uint64_t *pos)
Definition: idlist64.c:682
int GWEN_IdList64_HasId(const GWEN_IDLIST64 *idl, uint64_t id)
Definition: idlist64.c:391
GWEN_IDLIST64_ITERATOR * GWEN_IdList64_Iterator_new(GWEN_IDLIST64 *idl)
Definition: idlist64.c:700
#define GWEN_FREE_OBJECT(varname)
Definition: memory.h:61
#define NULL
Definition: binreloc.c:297
#define GWEN_LOGDOMAIN
Definition: logger.h:35
static int GWEN_IdTable64_DelId(GWEN_IDTABLE64 *idt, uint64_t id)
Definition: idlist64.c:132
static int GWEN_IdTable64_HasId(const GWEN_IDTABLE64 *idt, uint64_t id)
Definition: idlist64.c:118
int GWEN_IdList64_DelId(GWEN_IDLIST64 *idl, uint64_t id)
Definition: idlist64.c:368
static int __compDescending(const void *pa, const void *pb)
Definition: idlist64.c:465
int GWEN_IdList64_Sort(GWEN_IDLIST64 *idl)
Definition: idlist64.c:531
void GWEN_IdList64_free(GWEN_IDLIST64 *idl)
Definition: idlist64.c:257
void GWEN_IdList64_Iterator_free(GWEN_IDLIST64_ITERATOR *it)
Definition: idlist64.c:715
static int GWEN_IdTable64_AddId(GWEN_IDTABLE64 *idt, uint64_t id)
Definition: idlist64.c:86
uint64_t GWEN_IdList64_GetFirstId(GWEN_IDLIST64 *idl)
Definition: idlist64.c:668
uint64_t GWEN_IdList64_GetEntryCount(const GWEN_IDLIST64 *idl)
Definition: idlist64.c:575
static int GWEN_IdList64__Sort(GWEN_IDLIST64 *idl, int ascending)
Definition: idlist64.c:480
uint64_t GWEN_IdList64__GetNextId(const GWEN_IDLIST64 *idl, uint64_t *pos)
Definition: idlist64.c:615
#define GWEN_NEW_OBJECT(typ, varname)
Definition: memory.h:55
GWEN_IDTABLE64 * GWEN_IdTable64_new(void)
Definition: idlist64.c:50
static int GWEN_IdTable64_IsFull(const GWEN_IDTABLE64 *idt)
Definition: idlist64.c:155
void GWEN_IdList64_AddTable(GWEN_IDLIST64 *idl, GWEN_IDTABLE64 *idt)
Definition: idlist64.c:273
uint64_t GWEN_IdList64_Iterator_GetFirstId(GWEN_IDLIST64_ITERATOR *it)
Definition: idlist64.c:725
uint64_t GWEN_IdList64_GetNextId(GWEN_IDLIST64 *idl)
Definition: idlist64.c:675
int GWEN_IdList64_AddId(GWEN_IDLIST64 *idl, uint64_t id)
Definition: idlist64.c:311
static int __compAscending(const void *pa, const void *pb)
Definition: idlist64.c:450
int GWEN_IdList64_AppendId(GWEN_IDLIST64 *idl, uint64_t id)
Definition: idlist64.c:739
#define DBG_ERROR(dbg_logger, format, args...)
Definition: debug.h:97
GWEN_IDLIST64 * GWEN_IdList64_dup(const GWEN_IDLIST64 *idl)
Definition: idlist64.c:545
void GWEN_IdList64_Clear(GWEN_IDLIST64 *idl)
Definition: idlist64.c:427
#define DBG_INFO(dbg_logger, format, args...)
Definition: debug.h:178
void GWEN_IdList64_Attach(GWEN_IDLIST64 *idl)
Definition: idlist64.c:248
GWEN_IDLIST64 * GWEN_IdList64_new(void)
Definition: idlist64.c:237
static int GWEN_IdTable64_IsEmpty(const GWEN_IDTABLE64 *idt)
Definition: idlist64.c:148
void GWEN_IdList64_Clean(GWEN_IDLIST64 *idl)
Definition: idlist64.c:410
uint64_t GWEN_IdList64_Iterator_GetNextId(GWEN_IDLIST64_ITERATOR *it)
Definition: idlist64.c:732
static int GWEN_IdTable64_AppendId(GWEN_IDTABLE64 *idt, uint64_t id)
Definition: idlist64.c:102
uint64_t GWEN_IdList64__GetFirstId(const GWEN_IDLIST64 *idl, uint64_t *pos)
Definition: idlist64.c:585
void GWEN_IdTable64_free(GWEN_IDTABLE64 *idt)
Definition: idlist64.c:63
uint64_t GWEN_IdList64_GetNextId2(const GWEN_IDLIST64 *idl, uint64_t *pos)
Definition: idlist64.c:689
uint64_t GWEN_IdList64_GetIdAt(const GWEN_IDLIST64 *idl, uint64_t idx)
Definition: idlist64.c:767
struct GWEN_IDLIST64_ITERATOR GWEN_IDLIST64_ITERATOR
Definition: idlist64.h:37
struct GWEN_IDLIST64 GWEN_IDLIST64
Definition: idlist64.h:36
int GWEN_IdList64_ReverseSort(GWEN_IDLIST64 *idl)
Definition: idlist64.c:538