Commits

Sulaiman Mustafa committed 80c350b

تحسينات وتصليحات متفرقة:
أ. تحسين عزل متغيرات القوالب
ب. إعادة هيكلة الأدلة
ج. إكمال توثيق القوالب في chain.h
د. قلب مدخلات chain_insert لتتوافق مع باقي القوالب
ه. تحسين المنحنيات البيانية وإضافة مخطوطاتها

Comments (0)

Files changed (12)

     
     Contact: http://people.sigh.asia/~sulaiman/about/contact/
     
+    -----------------------------------------------------------------------
+    
+    TODO:
+    
+        chain_new_slice(array, from, to)
+        
+        
+        move to extension???
+        ?map(array, {  // ele1 is predefined
+        
+        })
+        ?reduce(array, { //ele1 ele2 are predefined
+        
+        })
+
+
+
 */
 
 #include <stdlib.h>
 
 
 
-#define chain_insert(chain, what, at)
+#define chain_insert(chain, where, what)
         
         Description: inserts an element at an arbitrary 
                      position in a chain array.
                                     returned by chain_new
                                     or equivalent.
                                     
-                        what        The element to be 
+                        where       The index at which 
+                                    `what' should be 
                                     inserted.
                                     
-                        at          The index at which 
-                                    `what' should be 
+                        what        The element to be 
                                     inserted.
         
         Returns: the element to be inserted
 
 #define CHAIN_MTS    sizeof(uint32_t *)*2
 
-#define chain_len(c) (*( ( (uint32_t *) (((void *)c)-CHAIN_MTS) )+1 ))
+#define chain_len(C) (*( ( (uint32_t *) (((void *)(C))-CHAIN_MTS) )+1 ))
 #define chain_new(cell_type) (cell_type*) chain_new_(sizeof(cell_type))
 
-#define chain_shove(buf, what) (buf = chain_resize_(buf, 0, 1), buf[0]=(what))
-#define chain_insert(buf, what, at) (buf = chain_resize_(buf, (at), 1), buf[(!at||(at)>chain_len(buf))?(chain_len(buf)-1):(at)]=(what))
-#define chain_push(buf, what) chain_insert(buf, what, ~((uint32_t) 0))
+#define chain_shove(C, what) ((C) = chain_resize_((C), 0, 1), (C)[0]=(what))
+#define chain_insert(C, where, what) ((C) = chain_resize_((C), (where), 1), \
+                                     (C)[((where)>chain_len(C))?(chain_len(C)-1):(where)]=(what))
+#define chain_push(C, what) chain_insert((C), ~((uint32_t) 0), (what))
 
-#define chain_remove(buf, where) (buf=chain_resize_(buf, where, -1))
-#define chain_pop(buf) (chain_remove(buf, ~((uint32_t) 0)),buf[chain_len(buf)]=buf[chain_len(buf)])
+#define chain_remove(C, where) ((C)=chain_resize_((C), (where), -1))
+#define chain_pop(C) (chain_remove((C), ~((uint32_t) 0)),(C)[chain_len(C)]=(C)[chain_len(C)])
 
-#define chain_insert_all(buf, where, what, length) (buf=chain_insertm_(buf, where, (what), length))
-#define chain_push_all(buf, what, length) (buf=chain_insertm_(buf, ~((uint32_t) 0), (what), length))
+#define chain_insert_all(C, where, what, length) ((C)=chain_insertm_((C), (where), (what), (length)))
+#define chain_push_all(C, what, length) ((C)=chain_insertm_((C), ~((uint32_t) 0), (what), (length)))
 
-#define chain_clip(buf, where) (buf=chain_clip_(buf, where))
+#define chain_clip(C, where) ((C)=chain_clip_((C), (where)))
 
 
 void* chain_new_(uint8_t size);
 	
 benchmark: tests
 	./tests --benchmark
-	gnuplot ../../benchmark/benchmark.plt
+	gnuplot plots/shove-insert-push.plt
+	gnuplot plots/shove.plt
 
 memcheck: tests
 	valgrind --tool=memcheck ./tests
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.