00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef DEBUG
00019 #define DEBUG
00020 #endif
00021
00022 #include <ucommon/ucommon.h>
00023
00024 #include <stdio.h>
00025
00026 using namespace UCOMMON_NAMESPACE;
00027
00028 typedef linked_value<int> ints;
00029
00030 static OrderedIndex list;
00031
00032 class member : public DLinkedObject
00033 {
00034 public:
00035 inline member(unsigned v) : DLinkedObject() {value = v;}
00036
00037 unsigned value;
00038 };
00039
00040 extern "C" int main()
00041 {
00042 linked_pointer<ints> ptr;
00043 unsigned count = 0;
00044
00045
00046
00047
00048 int xv = 3, xn = 5;
00049 ints v1(&list, xv);
00050 ints v2(&list);
00051 v2 = xn;
00052
00053 ptr = &list;
00054 while(ptr) {
00055 switch(++count)
00056 {
00057 case 1:
00058 assert(ptr->value == 3);
00059 break;
00060 case 2:
00061 assert(ptr->value == 5);
00062 }
00063 ++ptr;
00064 }
00065 assert(count == 2);
00066
00067 member ov1 = 1, ov2 = 2, ov3 = 3;
00068
00069 assert(ov2.value == 2);
00070
00071 objstack_t st;
00072 st.push(&ov1);
00073 st.push(&ov2);
00074 st.push(&ov3);
00075
00076 member *mv = (member *)st.pop();
00077 assert(mv->value == 3);
00078 st.pop();
00079 st.pop();
00080 assert(NULL == st.pop());
00081
00082 objqueue<member> que;
00083 que.add(&ov1);
00084 que.add(&ov2);
00085 que.add(&ov3);
00086 mv = que.pop();
00087 assert(mv->value == 3);
00088 mv = que.pull();
00089 assert(mv != NULL);
00090
00091
00092 return 0;
00093 }