1 #include <rudiments/singlylinkedlist.h> 2 #include <rudiments/stdio.h> 3 main(int argc,const char ** argv)4int main(int argc, const char **argv) { 5 6 singlylinkedlist<uint32_t> sll; 7 8 // apppend nodes to the list 9 sll.append(new singlylinkedlistnode<uint32_t>(5)); 10 sll.append(new singlylinkedlistnode<uint32_t>(6)); 11 sll.append(new singlylinkedlistnode<uint32_t>(7)); 12 13 // prepend nodes to the list 14 sll.prepend(new singlylinkedlistnode<uint32_t>(2)); 15 sll.prepend(new singlylinkedlistnode<uint32_t>(1)); 16 sll.prepend(new singlylinkedlistnode<uint32_t>(0)); 17 18 // insert nodes 19 sll.insertAfter(sll.find(2),new singlylinkedlistnode<uint32_t>(3)); 20 sll.insertAfter(sll.find(3),new singlylinkedlistnode<uint32_t>(4)); 21 22 // move nodes around 23 sll.prepend(new singlylinkedlistnode<uint32_t>(8)); 24 sll.prepend(new singlylinkedlistnode<uint32_t>(9)); 25 sll.prepend(new singlylinkedlistnode<uint32_t>(10)); 26 sll.moveAfter(sll.find(7),sll.find(8)); 27 sll.moveAfter(sll.find(8),sll.find(9)); 28 sll.moveAfter(sll.find(9),sll.find(10)); 29 30 // length 31 stdoutput.printf("The list contains %lld nodes.\n\n",sll.getLength()); 32 33 // print the list 34 stdoutput.write("Current contents:\n"); 35 sll.print(); 36 stdoutput.write('\n'); 37 38 // print the first 3 values in the list 39 stdoutput.write("First 3 values:\n"); 40 sll.print(3); 41 stdoutput.write('\n'); 42 } 43