list.hd
1 #REM
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 #PARAMETER(oType)
48 #DESCRIPTION(Type of values stored)
49 #CHECK
50 #REPLACE_PERHAPS_START(oT###ypeVar,oType)
51 #REPLACE_PERHAPS_START(oT###ypeSuffix,)
52 #REPLACE_PERHAPS_START(oT###ypeParamSuffix,oTypeSuffix)
53 #REPLACE_PERHAPS_START(oT###ypeParam,oType oTypeParamSuffix)
54 #REPLACE_PERHAPS_START(oT###ypeTouched,oTypeParam)
55 #REPLACE_PERHAPS_START(oT###ypeVarParam,oTypeVar oTypeParamSuffix)
56 #REPLACE_PERHAPS_START(oT###ypeResultSuffix,oTypeSuffix)
57 #REPLACE_PERHAPS_START(oT###ypeResult,oType oTypeResultSuffix)
58 #REPLACE(List,Global_list_oType)
59 #REPLACE(NSList,nslist_oType)
60 #FILES(list.cd list_i.hd list_u.hd)
61 #GENERAL(Global_list_u.ErwinHExt List_u.ErwinHExt)
62 #HEADER(List.ErwinHExt List_i.ErwinHExt List_d.ErwinHExt List_f.ErwinHExt List_ti.ErwinHExt List_n.ErwinHExt)
63 #CLASS_IDENTIFIER(List_class)
64 #CLASS_IDENTIFIER(NSList_class)
65 #SPLIT_TARGET(List)
66 #REM *****************************************************************************************
67 #OUTPUT(List_f.ErwinHExt)
68
69 #ifndef ERWIN_List_f_ErwinHExt
70 #define ERWIN_List_f_ErwinHExt
71
72 struct List_t;
73 #TYPEDEF_GLOBAL(aggregate List_t NSList_t)
74
75 #ifndef __cplusplus
76
77
78 typedef struct List_t List_t;
79 #endif
80 typedef List_t List_class;
81
82 #TYPEDEF_GLOBAL(aggregate List_class NSList_class)
83
84 typedef List_t *List_t_p;
85 #TYPEDEF_GLOBAL(List_t_p NSList_t_p)
86
87 typedef List_t const *List_t_const_p;
88 #TYPEDEF_GLOBAL(List_t_const_p NSList_t_const_p)
89
90 #define List_SIG __gen_sig__
91
92 ErwinGlobalDefines
93
94 #TYPEDEF_GLOBAL(Global_list_key_t list_key_t)
95
96
97 #ifndef Global_list_key_t
98 typedef void *Global_list_key_t;
99 #define Global_list_key_t Global_list_key_t
100 #define Global_LIST_KEY_ZERO ((Global_list_key_t)NULL)
101 #endif
102
103 #DEEPDECLS(List,HASH_RAW,CMP/NULL,ZERO,ICOPY,OCOPY,IFREE,OFREE,CONSTRUCTOR,DESTRUCTOR)
104 #REM HACK: currently, HAS_CONSTANT_ZERO is removed. It should be put back!
105 #REM
106 #REM These deep decls must be put into the _f file, otherwise the implementation might not see them.
107 #REM Probably some programs will not require some defines to be moved from the decls.h to the
108 #REM settings.h file because of the change, but otherwise, we might get very hard to find run-time
109 #REM problems when the application has different sized objects than the library.
110 #REM THIS BUG WAS VERY HARD TO FIND!
111
112 #endif
113
114 #REM *****************************************************************************************
115 #OUTPUT(List_n.ErwinHExt)
116
117 #CHECKINCLUDE(List)
118
119 #ifdef List_NEED_HEADER
120 #include "#List.ErwinHExt"
121 #endif
122
123 #REM *****************************************************************************************
124 #OUTPUT(List_ti.ErwinHExt)
125
126 #ifndef ERWIN_List_ti_ErwinHExt
127 #define ERWIN_List_ti_ErwinHExt
128
129 #define List_elt_t_KIND STRUCT
130 #define List_elt_t_TYPE_INFO TYPE_INFO_NAME(List_elt_t)
131 extern TYPE_INFO_T(List_elt_t);
132
133 #define List_elt_t_p_KIND POINTER
134 #define List_elt_t_p_TYPE_INFO TYPE_INFO_NAME(List_elt_t_p)
135 extern TYPE_INFO_T(List_elt_t_p);
136
137 #define List_elt_t_const_p_KIND POINTER
138 #define List_elt_t_const_p_TYPE_INFO TYPE_INFO_NAME(List_elt_t_const_p)
139 extern TYPE_INFO_T(List_elt_t_const_p);
140
141 #define List_t_KIND STRUCT
142 #define List_t_TYPE_INFO TYPE_INFO_NAME(List_t)
143 extern TYPE_INFO_T(List_t);
144
145 #define List_t_p_KIND POINTER
146 #define List_t_p_TYPE_INFO TYPE_INFO_NAME(List_t_p)
147 extern TYPE_INFO_T(List_t_p);
148
149 #define List_t_const_p_KIND POINTER
150 #define List_t_const_p_TYPE_INFO TYPE_INFO_NAME(List_t_const_p)
151 extern TYPE_INFO_T(List_t_const_p);
152
153 #define List_class###_TYPE_INFO List_t_TYPE_INFO
154 #define List_class_p###_TYPE_INFO List_t_p_TYPE_INFO
155 #define List_class_const_p###_TYPE_INFO List_t_const_p_TYPE_INFO
156
157 #endif
158
159 #REM *****************************************************************************************
160 #OUTPUT(List.ErwinHExt)
161
162 #DATE
163
164
165
166
167
168 #LICENCE
169
170 #ifdef ERWIN_DEBUG_INCLUDE
171 #warning "Including List.ErwinHExt"
172 #endif
173
174 #ifndef ERWIN_List_ErwinHExt
175 #define ERWIN_List_ErwinHExt
176
177 #ifdef ERWIN_DEBUG_INCLUDE
178 #warning "First inclusion of List.ErwinHExt"
179 #endif
180
181
182 #ifdef Global_ERWIN_COMPILING
183 # include "erwin/defs.h"
184 #else
185 # include <erwin/defs.h>
186 #endif
187
188
189 #include "#List_d.ErwinHExt"
190
191
192 #ifdef Global_ERWIN_COMPILING
193 # include "erwin/base.h"
194 #else
195 # include <erwin/base.h>
196 #endif
197
198
199 #ifdef Global_ERWIN_COMPILING
200 # include "erwin/forwards.h"
201 #else
202 # include <erwin/forwards.h>
203 #endif
204
205 #ifdef HAVE_STDIO_H
206 # include <stdio.h>
207 #endif
208
209 #include "#List_i.ErwinHExt"
210
211
212
213 #IFCPPONLY
214 #ELSE
215 #ifdef __cplusplus
216 extern "C" {
217 #endif
218 #ENDIF
219
220 #undef Global_list_errno
221
222 #if Global_ERWIN_GLOBAL_ERRNO
223 # define Global_list_errno Global_erwininternallisterrno
224
225
226
227 #endif
228
229 #undef Global_list_strerror
230 #define Global_list_strerror(X) Global_erwininternalliststrerror(X)
231
232
233
234
235
236
237
238 #undef Global_LIST_OK
239 #define Global_LIST_OK Global_ERWININTERNALLISTOK
240
241
242 #undef Global_LIST_IS_OK
243 #define Global_LIST_IS_OK(X) Global_ERWININTERNALLISTISOK(X)
244
245
246 #undef Global_LIST_IS_ERROR
247 #define Global_LIST_IS_ERROR(X) Global_ERWININTERNALLISTISERROR(X)
248
249
250 #undef Global_LIST_IS_WARNING
251 #define Global_LIST_IS_WARNING(X) Global_ERWININTERNALLISTISWARNING(X)
252
253
254 #undef Global_LIST_ERR_NOMEM
255 #define Global_LIST_ERR_NOMEM Global_ERWININTERNALLISTERRNOMEM
256
257
258
259
260 #undef Global_LIST_ERR_OUTOFRANGE
261 #define Global_LIST_ERR_OUTOFRANGE Global_ERWININTERNALLISTERROUTOFRANGE
262
263
264 #undef Global_LIST_ERR_ASSERTIONFAILED
265 #define Global_LIST_ERR_ASSERTIONFAILED Global_ERWININTERNALLISTERRASSERTIONFAILED
266
267
268
269
270
271
272
273
274 #undef Global_LIST_ERR_NOTCOMPILED
275 #define Global_LIST_ERR_NOTCOMPILED Global_ERWININTERNALLISTERRNOTCOMPILED
276
277
278
279
280
281
282
283
284 #undef Global_LIST_WARN_OUTOFRANGE
285 #define Global_LIST_WARN_OUTOFRANGE Global_ERWININTERNALLISTWARNOUTOFRANGE
286
287
288
289
290 typedef int List_index_t;
291 #TYPEDEF(List_index_t NSList_index_t)
292 typedef oType List_value_t;
293 #TYPEDEF(List_value_t NSList_value_t)
294
295 typedef int (*List_cmp_t) (oType const *, oType const *);
296 #TYPEDEF(List_cmp_t NSList_cmp_t)
297
298 typedef Global_ERWIN_BOOL (*List_feature_t)(oTypeParam);
299 #TYPEDEF(List_feature_t NSList_feature_t)
300
301 #ifndef List_MAP_T_DEFINED
302 #define List_MAP_T_DEFINED
303
304
305
306 typedef oType (*List_map_t)(oTypeParam);
307 #TYPEDEF(List_map_t NSList_map_t)
308
309 #endif
310 #define List_CMP_T_NULL ((List_cmp_t)NULL)
311
312 #ifdef __cplusplus
313 typedef bool (*List_cpp_feature_t)(oTypeParam);
314 #endif
315 #TYPEDEF_CXX(List_cpp_feature_t NSList_cpp_feature_t)
316
317
318 #TYPEDEF(List_element_ptr_t NSList_element_ptr_t)
319 #TYPEDEF_CXX(List_element_ref_t NSList_element_ref_t)
320
321 #IFEQ(oType,oTypeVar)
322 typedef oType *List_element_ptr_t;
323 #ifdef __cplusplus
324 typedef oType &List_element_ref_t;
325 #endif
326 #ELSE
327 typedef oType const *List_element_ptr_t;
328 #ifdef __cplusplus
329 typedef oType const &List_element_ref_t;
330 #endif
331 #ENDIF
332
333 typedef int (*List_combine_t) (List_element_ptr_t, oType const *);
334 #define List_COMBINE_T_NULL ((List_combine_t)NULL)
335
336 #TYPEDEF(List_combine_t NSList_combine_t)
337
338
339
340
341
342 Global_ERWIN_EXPORT
343 List_t *List_new (void) ATTR_MALLOC;
344
345
346
347
348
349
350 #if List_DYN_ZERO
351 Global_ERWIN_EXPORT
352 List_t *List_new_with_zero (oTypeTouched ) ATTR_MALLOC;
353
354 #endif
355
356 Global_ERWIN_EXPORT
357 oTypeResult List_zero (List_t const * ) ATTR_PURE;
358
359 #if !Global_ERWIN_GLOBAL_ERRNO
360
361 Global_ERWIN_EXPORT
362 int List_errno(List_t const *) ATTR_PURE;
363
364
365
366
367
368
369
370
371
372
373 Global_ERWIN_EXPORT
374 void List_clear_errno(List_t const * );
375
376
377
378
379
380
381
382
383
384
385 #else
386
387 #define List_errno(X) Global_list_errno
388
389
390
391
392
393
394
395
396
397
398 #define List_clear_errno(X) ((void)(Global_map_errno= Global_MAP_OK))
399
400
401
402
403
404
405
406
407
408 #endif
409
410
411 Global_ERWIN_EXPORT
412 List_t *List_copy (List_t const* );
413
414
415
416 Global_ERWIN_EXPORT
417 List_t *List_copy_err (List_t const* , int * );
418
419
420
421 Global_ERWIN_EXPORT
422 void List_delete (List_t* );
423
424
425
426
427
428 Global_ERWIN_EXPORT
429 void List_clear (List_t* );
430
431
432
433
434
435 Global_ERWIN_EXPORT
436 Global_list_key_t List_front (List_t const * ) ATTR_PURE;
437
438
439 Global_ERWIN_EXPORT
440 Global_list_key_t List_back (List_t const * ) ATTR_PURE;
441
442
443
444 Global_ERWIN_EXPORT
445 Global_list_key_t List_previous (List_t const * , Global_list_key_t ) ATTR_PURE;
446
447
448
449
450
451 Global_ERWIN_EXPORT
452 Global_list_key_t List_previous_raw (Global_list_key_t ) ATTR_PURE;
453
454
455
456
457
458
459
460 Global_ERWIN_EXPORT
461 Global_list_key_t List_next (List_t const * , Global_list_key_t ) ATTR_PURE;
462
463
464
465
466
467 Global_ERWIN_EXPORT
468 Global_list_key_t List_next_raw (Global_list_key_t ) ATTR_PURE;
469
470
471
472
473
474
475
476 Global_ERWIN_EXPORT
477 oTypeResult List_value (List_t const * , Global_list_key_t ) ATTR_PURE;
478
479
480
481
482
483 Global_ERWIN_EXPORT
484 oTypeResult List_value_raw (Global_list_key_t ) ATTR_PURE;
485
486
487
488
489
490 Global_ERWIN_EXPORT
491 void List_overwrite (List_t * , Global_list_key_t , oTypeTouched );
492
493
494
495
496
497 Global_ERWIN_EXPORT
498 oTypeResult List_first (List_t const * ) ATTR_PURE;
499
500
501 Global_ERWIN_EXPORT
502 oTypeResult List_last (List_t const * ) ATTR_PURE;
503
504
505 Global_ERWIN_EXPORT
506 Global_list_key_t List_nth_key (List_t const * , int ) ATTR_PURE;
507
508
509
510
511 Global_ERWIN_EXPORT
512 oTypeResult List_nth (List_t const * , int ) ATTR_PURE;
513
514
515 Global_ERWIN_EXPORT
516 List_element_ptr_t List_value_ptr (List_t const * , Global_list_key_t ) ATTR_PURE;
517
518
519
520
521
522 Global_ERWIN_EXPORT
523 void List_erase (List_t * , Global_list_key_t );
524
525
526
527
528
529
530
531
532
533
534 Global_ERWIN_EXPORT
535 void List_erase_in_loop (
536 Global_list_key_t * ,
537 List_t * , Global_list_key_t ,
538 Global_ERWIN_BOOL );
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557 Global_ERWIN_EXPORT
558 Global_list_key_t List_append (List_t * , oTypeTouched );
559
560
561 Global_ERWIN_EXPORT
562 Global_list_key_t List_prepend (List_t * , oTypeTouched );
563
564
565 Global_ERWIN_EXPORT
566 Global_list_key_t List_insert_after (List_t * , Global_list_key_t , oTypeTouched );
567
568
569
570
571 Global_ERWIN_EXPORT
572 Global_list_key_t List_insert_before (List_t * , Global_list_key_t , oTypeTouched );
573
574
575
576
577 Global_ERWIN_EXPORT
578 Global_list_key_t List_insert (
579 List_t * ,
580 Global_list_key_t , oTypeTouched , Global_ERWIN_BOOL );
581
582
583
584
585
586 Global_ERWIN_EXPORT
587 void List_append_list (List_t * , List_t const * );
588
589
590 Global_ERWIN_EXPORT
591 void List_prepend_list (List_t * , List_t const * );
592
593
594 Global_ERWIN_EXPORT
595 void List_insert_list_after (List_t * , Global_list_key_t , List_t const * );
596
597
598
599
600 Global_ERWIN_EXPORT
601 void List_insert_list_before (List_t * , Global_list_key_t , List_t const * );
602
603
604
605
606 Global_ERWIN_EXPORT
607 void List_insert_list (
608 List_t * ,
609 Global_list_key_t , List_t const * , Global_ERWIN_BOOL );
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631 #define List_forall(v,i,h) \
632 for(List_init_iterator(v,&(i)); \
633 List_next_iteration(v,&(i),&(h));)
634
635 #define List_forall_reverse(v,i,h) \
636 for(List_init_iterator_reverse(v,&(i)); \
637 List_next_iteration_reverse(v,&(i),&(h));)
638
639 #define List_forall_ptr(v,i,h) \
640 for(List_init_iterator((v),&(i)); \
641 List_next_iteration_ptr(v,&(i),&(h));) \
642
643 #define List_forall_ptr_reverse(v,i,h) \
644 for(List_init_iterator_reverse(v,&(i)); \
645 List_next_iteration_ptr_reverse((i),&(h));)
646
647 #define List_forall_keys(v,i) \
648 for(List_init_iterator(v,&(i)); \
649 List_next_iteration(v,&(i),NULL);)
650
651 #define List_forall_keys_reverse(v,i) \
652 for(List_init_iterator_reverse(v,&(i)); \
653 List_next_iteration_reverse(v,&(i),NULL);)
654
655 #define List_init_iterator(v,i) *(i)= NULL
656 #define List_init_iterator_reverse(v,i) *(i)= NULL
657
658
659 Global_ERWIN_EXPORT
660 Global_ERWIN_BOOL List_next_iteration (
661 List_t const * , Global_list_key_t * , oType * );
662
663
664 Global_ERWIN_EXPORT
665 Global_ERWIN_BOOL List_next_iteration_reverse (
666 List_t const * , Global_list_key_t * , oType * );
667
668
669 Global_ERWIN_EXPORT
670 Global_ERWIN_BOOL List_next_iteration_ptr (
671 List_t * , Global_list_key_t * , oTypeVar ** );
672
673
674 Global_ERWIN_EXPORT
675 Global_ERWIN_BOOL List_next_iteration_ptr_reverse (
676 List_t * , Global_list_key_t * , oTypeVar ** );
677
678
679
680 Global_ERWIN_EXPORT
681 int List_nentries (List_t const * );
682
683
684
685
686
687
688
689
690
691
692
693 Global_ERWIN_EXPORT
694 Global_ERWIN_BOOL List_empty (List_t const * );
695
696
697 #if 0
698
699 Global_ERWIN_EXPORT
700 void List_map (List_t * , List_map_t );
701
702
703 Global_ERWIN_EXPORT
704 int List_cmp (List_t const *, List_t const *, List_cmp_t ) ATTR_PURE;
705
706
707
708
709
710
711
712
713
714
715 #endif
716
717 Global_ERWIN_EXPORT
718 Global_hashval_t List_hash_raw (List_t const *) ATTR_PURE;
719
720
721
722
723
724
725
726
727
728
729 ERWIN_WRAPPER
730 Global_hashval_t List_hash (List_t const *);
731
732
733 ERWIN_WRAPPER
734 Global_hashval_t List_hash (List_t const *x)
735 {
736 return List_hash_raw(x);
737 }
738
739
740
741 #IFCPPONLY
742 #ELSE
743 #ifdef __cplusplus
744 }
745 #endif
746 #ENDIF
747
748 struct List_t
749 #ifdef List_SUPER_CLASS
750 : List_SUPER_CLASS_ACCESS List_SUPER_CLASS
751 #endif
752 {
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789 List_STD_MEMBERS(List_t)
790
791 #ifdef __cplusplus
792 public:
793 #endif
794
795 List_record
796
797 #ifdef __cplusplus
798
799 List_t *it() { return this; }
800
801
802 List_t const *it() const { return this; }
803
804
805 public:
806 #ifdef __cplusplus
807 #if !Global_ERWIN_DEFAULT_NEW_DELETE
808 static void *operator new(size_t);
809 static void operator delete(void *, size_t);
810 static void *operator new[](size_t);
811 static void operator delete[](void *, size_t);
812 #endif
813 #endif
814
815
816 List_t (void);
817
818 static List_t const &static_zero();
819
820 #if List_DYN_ZERO
821 Global_ERWIN_EXPLICIT List_t (oTypeTouched);
822 #endif
823
824 void _constructor (void);
825 void _destructor (void);
826
827
828
829 protected:
830 #ifndef NDEBUG
831 void cn() const;
832 void cn(void const *) const;
833 #else
834
835 static void cn() {}
836 static void cn(void const *) {}
837 #endif
838
839 public:
840
841 #if !Global_ERWIN_GLOBAL_ERRNO
842 int get_errno(void) const { return it()->m_errno; }
843 void clear_errno(void) const { List_clear_errno (it()); }
844 #else
845 static int get_errno(void) { return Global_list_errno; }
846 static void clear_errno(void) { Global_list_errno= Global_LIST_OK; }
847 #endif
848
849 List_t &clear() { cn(); List_clear (it()); return *this; }
850
851
852 List_t &operator=(List_t const &);
853 List_t &operator=(List_t const *);
854
855
856 ~List_t ();
857
858
859 operator List_t const *() const { cn(); return it(); }
860 operator List_t *() { cn(); return it(); }
861
862 Global_list_key_t front () const
863 { cn(); return List_front (it()); }
864
865 Global_list_key_t back () const
866 { cn(); return List_back (it()); }
867
868 Global_list_key_t previous (Global_list_key_t k) const
869 { cn(); return List_previous (it(), k); }
870
871 Global_list_key_t prev (Global_list_key_t k) const
872 { return previous(k); }
873
874 Global_list_key_t next (Global_list_key_t k) const
875 { cn(); return List_next (it(), k); }
876
877 Global_list_key_t nth_key (int k) const
878 { cn(); return List_nth_key (it(), k); }
879
880 oTypeResult nth (int k) const
881 { return List_nth (it(), k); }
882
883 void erase (Global_list_key_t k)
884 { cn(); List_erase (it(), k); }
885
886 void erase (Global_list_key_t &iter, Global_list_key_t k, bool reverse List_DEFAULT_ARG(false))
887 { cn(); List_erase_in_loop (&iter, it(), k, reverse); }
888
889 void erase_in_loop (Global_list_key_t &iter, Global_list_key_t k,
890 bool reverse List_DEFAULT_ARG (false))
891 { cn(); List_erase_in_loop (&iter, it(), k, reverse); }
892
893 oTypeResult value(Global_list_key_t k) const
894 { return List_value (it(), k); }
895
896 oTypeResult first() const
897 { return List_first (it()); }
898
899 oTypeResult last() const
900 { return List_last (it()); }
901
902 List_element_ptr_t value_ptr(Global_list_key_t k)
903 { cn(); return List_value_ptr (it(), k); }
904
905 List_element_ref_t value_ref(Global_list_key_t k)
906 { cn(); return *List_value_ptr (it(), k); }
907
908 Global_list_key_t append (oTypeTouched o)
909 { cn(); return List_append (it(), o); }
910
911 Global_list_key_t prepend (oTypeTouched o)
912 { cn(); return List_prepend (it(), o); }
913
914 Global_list_key_t insert_before (Global_list_key_t k, oTypeTouched o)
915 { cn(); return List_insert_before (it(), k, o); }
916
917 Global_list_key_t insert_after (Global_list_key_t k, oTypeTouched o)
918 { cn(); return List_insert_after (it(), k, o); }
919
920 void overwrite (Global_list_key_t k, oTypeTouched o)
921 { cn(); List_overwrite (it(), k, o); }
922
923 Global_list_key_t insert (Global_list_key_t k, oTypeTouched o, bool backwards)
924 { cn(); return List_insert (it(), k, o, backwards); }
925
926 List_t &operator<<(oTypeTouched o)
927 { cn(); List_append (it(), o); return *this; }
928
929 List_t &append_list (List_t const *x)
930 { cn(x); List_append_list (it(), x->it()); return *this; }
931 List_t &append_list (List_t const &x)
932 { cn(x); List_append_list (it(), x.it()); return *this; }
933
934 List_t &prepend_list (List_t const *x)
935 { cn(x); List_prepend_list (it(), x->it()); return *this; }
936 List_t &prepend_list (List_t const &x)
937 { cn(x); List_prepend_list (it(), x.it()); return *this; }
938
939 List_t &insert_list_before (Global_list_key_t k, List_t const *x)
940 { cn(x); List_insert_list_before (it(), k, x->it()); return *this; }
941 List_t &insert_list_before (Global_list_key_t k, List_t const &x)
942 { cn(x); List_insert_list_before (it(), k, x.it()); return *this; }
943
944 List_t &insert_list_after (Global_list_key_t k, List_t const *x)
945 { cn(x); List_insert_list_after (it(), k, x->it()); return *this; }
946 List_t &insert_list_after (Global_list_key_t k, List_t const &x)
947 { cn(x); List_insert_list_after (it(), k, x.it()); return *this; }
948
949 List_t &insert_list (Global_list_key_t k, List_t const *x, bool backwards)
950 { cn(); List_insert_list (it(), k, x->it(), backwards); return *this; }
951 List_t &insert_list (Global_list_key_t k, List_t const &x, bool backwards)
952 { cn(); List_insert_list (it(), k, x.it(), backwards); return *this; }
953
954 #if List_DIRECT_RECURSION == 0
955 List_t &append (List_t const *x)
956 { cn(x); List_append_list (it(), x->it()); return *this; }
957 List_t &append (List_t const &x)
958 { cn(x); List_append_list (it(), x.it()); return *this; }
959
960 List_t &prepend (List_t const *x)
961 { cn(x); List_prepend_list (it(), x->it()); return *this; }
962 List_t &prepend (List_t const &x)
963 { cn(x); List_prepend_list (it(), x.it()); return *this; }
964
965 List_t &insert_before (Global_list_key_t k, List_t const *x)
966 { cn(x); List_insert_list_before (it(), k, x->it()); return *this; }
967 List_t &insert_before (Global_list_key_t k, List_t const &x)
968 { cn(x); List_insert_list_before (it(), k, x.it()); return *this; }
969
970 List_t &insert_after (Global_list_key_t k, List_t const *x)
971 { cn(x); List_insert_list_after (it(), k, x->it()); return *this; }
972 List_t &insert_after (Global_list_key_t k, List_t const &x)
973 { cn(x); List_insert_list_after (it(), k, x.it()); return *this; }
974
975 List_t &insert (Global_list_key_t k, List_t const *x, bool backwards)
976 { cn(); List_insert_list (it(), k, x->it(), backwards); return *this; }
977 List_t &insert (Global_list_key_t k, List_t const &x, bool backwards)
978 { cn(); List_insert_list (it(), k, x.it(), backwards); return *this; }
979 #endif
980
981
982
983
984
985
986
987 Global_list_key_t init_iterator () const
988 {
989 cn();
990 Global_list_key_t a;
991 List_init_iterator (it(), &a);
992 return a;
993 }
994
995 Global_list_key_t init_iterator_reverse () const
996 {
997 cn();
998 Global_list_key_t a;
999 List_init_iterator_reverse (it(), &a);
1000 return a;
1001 }
1002
1003 bool next_iteration (Global_list_key_t *a, oType *b) const
1004 {
1005 cn();
1006 return Global_ERWIN_TO_BOOL (List_next_iteration (this, a, b));
1007 }
1008
1009
1010 bool next_iteration_ptr (Global_list_key_t *a, oTypeVar **b)
1011 {
1012 cn();
1013 return Global_ERWIN_TO_BOOL (List_next_iteration_ptr (this, a, b));
1014 }
1015
1016 bool next_iteration_reverse (Global_list_key_t *a, oType *b) const
1017 {
1018 cn();
1019 return Global_ERWIN_TO_BOOL (List_next_iteration_reverse (this, a, b));
1020 }
1021
1022
1023 bool next_iteration_ptr_reverse (Global_list_key_t *a, oTypeVar **b)
1024 {
1025 cn();
1026 return Global_ERWIN_TO_BOOL (List_next_iteration_ptr_reverse (this, a, b));
1027 }
1028
1029 int nentries () const { return List_nentries (it()); }
1030 bool empty () const { return Global_ERWIN_TO_BOOL(List_empty (it())); }
1031 bool non_empty () const { return !List_empty (it()); }
1032
1033 #if 0
1034
1035 int cmp (List_t const *other,
1036 List_cmp_t cmp List_DEFAULT_ARG(List_CMP_T_NULL)) const
1037 {
1038 if (this == NULL)
1039 return other == NULL ? 0 : -1;
1040 if (other == NULL)
1041 return +1;
1042 return List_cmp(it(), other->it(), cmp);
1043 }
1044
1045 int cmp (List_t const &other,
1046 List_cmp_t cmp_func List_DEFAULT_ARG(List_CMP_T_NULL)) const
1047 {
1048 return cmp (&other, cmp_func);
1049 }
1050
1051 bool operator== (List_t const &b) const { return cmp(b,List_CMP_T_NULL) == 0; }
1052 bool operator== (List_t const *b) const { return cmp(b,List_CMP_T_NULL) == 0; }
1053
1054 bool operator!= (List_t const &b) const { return cmp(b,List_CMP_T_NULL) != 0; }
1055 bool operator!= (List_t const *b) const { return cmp(b,List_CMP_T_NULL) != 0; }
1056
1057 bool operator<= (List_t const &b) const { return cmp(b,List_CMP_T_NULL) <= 0; }
1058 bool operator<= (List_t const *b) const { return cmp(b,List_CMP_T_NULL) <= 0; }
1059
1060 bool operator>= (List_t const &b) const { return cmp(b,List_CMP_T_NULL) >= 0; }
1061 bool operator>= (List_t const *b) const { return cmp(b,List_CMP_T_NULL) >= 0; }
1062
1063 bool operator< (List_t const &b) const { return cmp(b,List_CMP_T_NULL) < 0; }
1064 bool operator< (List_t const *b) const { return cmp(b,List_CMP_T_NULL) < 0; }
1065
1066 bool operator> (List_t const &b) const { return cmp(b,List_CMP_T_NULL) > 0; }
1067 bool operator> (List_t const *b) const { return cmp(b,List_CMP_T_NULL) > 0; }
1068 #endif
1069
1070
1071 #endif
1072 };
1073
1074 #undef List_LOCAL_WRAPPER
1075
1076 #ifdef __cplusplus
1077
1078 #IFEQ(0,0)
1079
1080
1081
1082
1083 extern "C++" {
1084 ERWIN_WRAPPER
1085 List_t *Global_erwin_ptr_of(List_t *x) { return x; }
1086
1087 ERWIN_WRAPPER
1088 List_t *Global_erwin_ptr_of(List_t &x) { return &x; }
1089
1090 ERWIN_WRAPPER
1091 List_t const *Global_erwin_ptr_const_of (List_t const *x) { return x; }
1092
1093 ERWIN_WRAPPER
1094 List_t const *Global_erwin_ptr_const_of (List_t const &x) { return &x; }
1095 }
1096
1097 #ELSE
1098
1099 #ifndef Global_erwin_ptr_of
1100 #define Global_erwin_ptr_of(x) x
1101 #endif
1102
1103 #ifndef Global_erwin_ptr_const_of
1104 #define Global_erwin_ptr_const_of(x) x
1105 #endif
1106
1107 #ENDIF
1108
1109
1110 #ifndef Global_list_forall
1111 #define Global_list_forall(v,i,h) \
1112 for ((i)= Global_erwin_ptr_const_of(v)->init_iterator(); \
1113 Global_erwin_ptr_const_of(v)->next_iteration(&(i),&(h));)
1114 #endif
1115
1116
1117 #ifndef Global_list_forall_ptr
1118 #define Global_list_forall_ptr(v,i,h) \
1119 for ((i)= Global_erwin_ptr_of(v)->init_iterator(); \
1120 Global_erwin_ptr_of(v)->next_iteration_ptr(&(i),&(h));)
1121 #endif
1122
1123 #ifndef Global_list_forall_reverse
1124 #define Global_list_forall_reverse(v,i,h) \
1125 for ((i)= Global_erwin_ptr_const_of(v)->init_iterator(); \
1126 Global_erwin_ptr_const_of(v)->next_iteration_reverse(&(i),&(h));)
1127 #endif
1128
1129 #ifndef Global_list_forall_ptr_reverse
1130 #define Global_list_forall_ptr_reverse(v,i,h) \
1131 for ((i)= Global_erwin_ptr_of(v)->init_iterator(); \
1132 Global_erwin_ptr_of(v)->next_iteration_ptr_reverse(&(i),&(h));)
1133 #endif
1134
1135 #ifndef Global_list_forall_keys
1136 #define Global_list_forall_keys(v,i) \
1137 for ((i)= Global_erwin_ptr_const_of(v)->init_iterator(); \
1138 Global_erwin_ptr_const_of(v)->next_iteration(&(i),NULL);)
1139 #endif
1140
1141 #ifndef Global_list_forall_keys_reverse
1142 #define Global_list_forall_keys_reverse(v,i) \
1143 for ((i)= Global_erwin_ptr_const_of(v)->init_iterator(); \
1144 Global_erwin_ptr_const_of(v)->next_iteration_reverse(&(i),NULL);)
1145 #endif
1146
1147 #ifndef Global_list_forall_values
1148 #define Global_list_forall_values(v,h) \
1149 for (Global_list_key_t ERWIN_GENSYM(erwin_local_j)= \
1150 Global_erwin_ptr_const_of(v)->init_iterator(); \
1151 Global_erwin_ptr_const_of(v)->next_iteration( \
1152 &ERWIN_GENSYM(erwin_local_j),&(h));)
1153 #endif
1154
1155 #ifndef Global_list_forall_values_ptr
1156 #define Global_list_forall_values_ptr(v,h) \
1157 for (Global_list_key_t ERWIN_GENSYM(erwin_local_j)= \
1158 Global_erwin_ptr_of(v)->init_iterator(); \
1159 Global_erwin_ptr_of(v)->next_iteration_ptr( \
1160 &ERWIN_GENSYM(erwin_local_j),&(h));)
1161 #endif
1162
1163 #ifndef Global_list_forall_values_reverse
1164 #define Global_list_forall_values_reverse(v,h) \
1165 for (Global_list_key_t ERWIN_GENSYM(erwin_local_j)= \
1166 Global_erwin_ptr_const_of(v)->init_iterator(); \
1167 Global_erwin_ptr_const_of(v)->next_iteration_reverse( \
1168 &ERWIN_GENSYM(erwin_local_j),&(h));)
1169 #endif
1170
1171 #ifndef Global_list_forall_values_ptr_reverse
1172 #define Global_list_forall_values_ptr_reverse(v,h) \
1173 for (Global_list_key_t ERWIN_GENSYM(erwin_local_j)= \
1174 Global_erwin_ptr_of(v)->init_iterator(); \
1175 Global_erwin_ptr_of(v)->next_iteration_ptr_reserve( \
1176 &ERWIN_GENSYM(erwin_local_j),&(h));)
1177 #endif
1178
1179 #endif
1180
1181 #endif