💾 Archived View for gmi.noulin.net › gitRepositories › staticList › file › main.c.gmi captured on 2023-07-10 at 15:56:09. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
main.c (3841B)
1 #! /usr/bin/env sheepy 2 /* or direct path to sheepy: #! /usr/local/bin/sheepy */ 3 4 #include "libsheepyObject.h" 5 #include "staticList.h" 6 7 int argc; char **argv; 8 9 int main(int ARGC, char** ARGV) { 10 11 argc = ARGC; argv = ARGV; 12 13 initLibsheepy(argv[0]); 14 setLogMode(LOG_FUNC); 15 16 puts("C template"); 17 18 staticListT(slt, u32, 3); 19 slt sl; 20 21 staticListInit(sl); 22 23 logPtr(sl.head); 24 logPtr(sl.last); 25 staticListPush(sl); 26 staticListLast(sl) = 1; 27 logPtr(sl.head); 28 logPtr(sl.last); 29 staticListPush(sl); 30 staticListLast(sl) = 10; 31 logPtr(sl.head); 32 logPtr(sl.last); 33 staticListPop(sl); 34 logPtr(sl.head); 35 logPtr(sl.last); 36 staticListPop(sl); 37 logPtr(sl.head); 38 logPtr(sl.last); 39 staticListPop(sl); 40 41 42 logPtr(sl.head); 43 logPtr(sl.last); 44 staticListPush(sl); 45 staticListLast(sl) = 1; 46 logPtr(sl.head); 47 logPtr(sl.head->next); 48 logPtr(sl.head->prev); 49 logPtr(sl.last); 50 logPtr(sl.last->next); 51 logPtr(sl.last->prev); 52 staticListPush(sl); 53 staticListLast(sl) = 10; 54 logPtr(sl.head); 55 logPtr(sl.head->next); 56 logPtr(sl.head->prev); 57 logPtr(sl.last); 58 logPtr(sl.last->next); 59 logPtr(sl.last->prev); 60 staticListPush(sl); 61 staticListLast(sl) = 100; 62 logPtr(sl.head); 63 logPtr(sl.head->next); 64 logPtr(sl.head->prev); 65 logPtr(sl.last); 66 logPtr(sl.last->next); 67 logPtr(sl.last->prev); 68 logPtr(sl.last->prev->prev); 69 logPtr(sl.last->prev->next); 70 var idx = sl.head->next; 71 staticListDelNode(sl, idx); 72 logPtr(sl.head); 73 logPtr(sl.head->next); 74 logPtr(sl.head->prev); 75 logPtr(sl.last); 76 logPtr(sl.last->next); 77 logPtr(sl.last->prev); 78 idx = sl.head; 79 staticListDelNode(sl, idx); 80 logPtr(sl.head); 81 logPtr(sl.head->next); 82 logPtr(sl.head->prev); 83 logPtr(sl.last); 84 logPtr(sl.last->next); 85 logPtr(sl.last->prev); 86 idx = sl.head; 87 staticListDelNode(sl, idx); 88 logPtr(sl.head); 89 logPtr(sl.last); 90 91 92 logPtr(sl.head); 93 logPtr(sl.last); 94 staticListPush(sl); 95 staticListLast(sl) = 1; 96 logPtr(sl.head); 97 logPtr(sl.last); 98 staticListPush(sl); 99 staticListLast(sl) = 10; 100 logPtr(sl.head); 101 logPtr(sl.last); 102 staticListPush(sl); 103 staticListLast(sl) = 100; 104 logPtr(sl.head); 105 logPtr(sl.last); 106 107 staticListForEach(sl, e) { 108 logVarG(e->elem); 109 } 110 111 logPtr(sl.head); 112 logPtr(sl.head->next); 113 logPtr(sl.head->prev); 114 logPtr(sl.last); 115 logPtr(sl.last->next); 116 logPtr(sl.last->prev); 117 logPtr(sl.last->prev->prev); 118 logPtr(sl.last->prev->next); 119 var e1 = sl.head; 120 var e2 = sl.last; 121 logI("\nswap"); 122 staticListSwap(sl, e1, e2); 123 logPtr(sl.head); 124 logPtr(sl.head->next); 125 logPtr(sl.head->prev); 126 logPtr(sl.last); 127 logPtr(sl.last->next); 128 logPtr(sl.last->prev); 129 logPtr(sl.last->prev->prev); 130 logPtr(sl.last->prev->next); 131 staticListForEach(sl, e) { 132 logVarG(e->elem); 133 } 134 135 e1 = sl.head; 136 e2 = sl.head->next; 137 logI("\nswap"); 138 staticListSwap(sl, e1, e2); 139 staticListForEach(sl, e) { 140 logVarG(e->elem); 141 } 142 143 e1 = sl.last; 144 e2 = sl.last->prev; 145 logI("\nswap"); 146 staticListSwap(sl, e1, e2); 147 staticListForEach(sl, e) { 148 logVarG(e->elem); 149 } 150 151 staticListPop(sl); 152 logI("pop"); 153 staticListForEach(sl, e) { 154 logVarG(e->elem); 155 } 156 157 e1 = sl.head; 158 e2 = sl.last; 159 logI("\nswap"); 160 staticListSwap(sl, e1, e2); 161 staticListForEach(sl, e) { 162 logVarG(e->elem); 163 } 164 165 put 166 logI("unlink head"); 167 staticListPush(sl); 168 staticListLast(sl) = 100; 169 put 170 staticListForEach(sl, e) { 171 logVarG(e->elem); 172 } 173 e1 = sl.head; 174 staticListUnlink(sl, e1); 175 e2 = sl.last; 176 staticListInsertAfter(sl, e2, e1); 177 put 178 staticListForEach(sl, e) { 179 logVarG(e->elem); 180 } 181 182 put 183 logI("unlink last"); 184 e1 = sl.last; 185 staticListUnlink(sl, e1); 186 e2 = sl.head; 187 staticListInsertAfter(sl, e2, e1); 188 put 189 staticListForEach(sl, e) { 190 logVarG(e->elem); 191 } 192 193 /* staticListWriteFilename(sl, "linked.bin"); */ 194 /* staticListReadFilename(sl, "linked.bin"); */ 195 }