diff options
author | cathook <b01902109@csie.ntu.edu.tw> | 2014-04-19 23:39:29 +0800 |
---|---|---|
committer | cathook <b01902109@csie.ntu.edu.tw> | 2014-04-19 23:39:29 +0800 |
commit | c3ddd993afbdfe37e85df4a54738469dcbc0a37c (patch) | |
tree | 06c56613d6dc5189f4ac3535507d8fdd6a761643 | |
parent | e9a16c4ef0ea782d7db8d788c455ea946eaab039 (diff) | |
download | meow-c3ddd993afbdfe37e85df4a54738469dcbc0a37c.tar meow-c3ddd993afbdfe37e85df4a54738469dcbc0a37c.tar.gz meow-c3ddd993afbdfe37e85df4a54738469dcbc0a37c.tar.bz2 meow-c3ddd993afbdfe37e85df4a54738469dcbc0a37c.tar.lz meow-c3ddd993afbdfe37e85df4a54738469dcbc0a37c.tar.xz meow-c3ddd993afbdfe37e85df4a54738469dcbc0a37c.tar.zst meow-c3ddd993afbdfe37e85df4a54738469dcbc0a37c.zip |
Add description
-rw-r--r-- | README.asciidoc | 357 | ||||
-rw-r--r-- | README.html | 1845 | ||||
-rw-r--r-- | description.asciidoc | 38 | ||||
-rw-r--r-- | meowpp/Usage.h | 63 | ||||
-rw-r--r-- | meowpp/dsa/DisjointSet.h | 26 | ||||
-rw-r--r-- | meowpp/dsa/Heaps.h | 84 | ||||
-rw-r--r-- | meowpp/dsa/KD_Tree.h | 42 | ||||
-rw-r--r-- | meowpp/dsa/MergeableHeap.hpp | 3 | ||||
-rw-r--r-- | meowpp/dsa/SegmentTree.h | 92 | ||||
-rw-r--r-- | meowpp/dsa/SegmentTree.hpp | 172 | ||||
-rw-r--r-- | meowpp/dsa/SplayTree.h | 75 | ||||
-rw-r--r-- | meowpp/oo/Register_Implement.h | 20 | ||||
-rw-r--r-- | meowpp/oo/Register_Implement.hpp | 5 | ||||
-rw-r--r-- | meowpp/utility.h | 55 | ||||
-rwxr-xr-x | readme_generate.py | 6 |
15 files changed, 2827 insertions, 56 deletions
diff --git a/README.asciidoc b/README.asciidoc index 8058527..3b3c9d7 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -1,14 +1,202 @@ -==== hi!! += meow -=== MergeableHeap<Key, Value> + +== Description +一個不需要, 也不建議先compile成obj files的templates. + +TIP: *README.html* is more beautiful. + +== File Tree +=== *meowpp/* C++ templates + +[width="90%"] +* *utility.h* some useful functions, + `stringPringf()` , `stringReplace` , `cstringEndWith` , + `debugPrintf()` , `messagePrintf()` , `constant PI` , + `noEPS()` , `normalize()` , `denormalize` , + `ratioMapping` , `inRange()` , `squ()` , `average()` +* *Usage.h* `class Usage` +* *colors/* Color splces and transformer +** *RGB.h* `class RGBi` , `class RGBf` +** *YUV.h* `class YUVi` , `class YUVf` , `RGB_to_YUV()` , `YUV_to_RGB` +** *HSL.h* `class HSLf` , `RGB_to_HSL()` , `HSL_to_RGB` , + `YUV_to_HSL()` , `HSL_to_YUV` +** *HSV.h* `class HSVf` , `RGB_to_HSV()` , `HSV_to_RGB` , + `YUV_to_HSV()` , `HSV_to_YUV` , + `HSL_to_HSV()` , `HSV_to_HSL` +* *dsa/* Data Structures and Algorithms +** *DisjointSet.h* `class DisjointSet` +** *Heaps.h* `class MergeableHeap` +** *KD_Tree.h* `class KD_Tree` +** *SplayTree.h* `class SplayTree` +* *oo/* +** *Register_Implement.h* `class RegisterInterface` , + `class ImplementInterface` + +== Structures/Classes/Functions + + +=== meow:: *Functios* in utility.h +[options="header",width="100%",cols="1>s,5<,1<,10<",grid="rows"] +|============================================================== +|Name | Parameters | Return Type | Description +|stringPrintf |(char const * fmt, ...)|std::string | +Format print to C++ string and return it +|stringReplace |(std::string str, + +std::string const& from, + +std::string const& to) | std::string | +Return a string like `str`, but all `from` be replaced by `to` +|cstringEndWith |(char const* str, int n, ...) | bool | +Return whether `str` is end with one of the c-string you specify in +the parameters or not +|debugPrintf |(char const* fmt, ...) | void| +Print debug message (file name, line number, ...etc) when `DEBUG` is +defined +|messagePrintf |(int level_change, char const* fmt, ...) | void| +階層式的訊息輸出 +|noEPS |(double value, double eps = 1e-9) | double | +如果abs(輸入的數值) < eps, 則回傳0, 否則回傳輸入的數值 +|normalize |(double lower, double upper, + +double value) | double | +(value - lower) / (upper - lower) +|denormalize |(double lower, double upper, + +double ratio) | double | +lower + (upper - lower) * ratio +|ratioMapping |(double l1, double u1, + +double m1, double l2, + +double u2) +| double | +denormalize(l2, u2, normalize(l1, u1, m1)) +|inRange<T> |(T const& mn, T const& mx, + +T const& v) | T | +std::max(mn, std::min(mx, v)) +|squ<T> |(T const& x) | T| +x * x +|average<T>|(T const& beg, T const& end, + +double sigs)| T| +只將 `sigs` 個標準差以內的數據拿來取平均 +|average<T>|(T const& beg, T const& end, + +T const& p, double sigs)| T| +同上, 不過這次用 `p` 來加權平均 +|============================================================== + +[NOTE] +`stringReplace()` 不是用什麼好方法寫的因此執行效率很低請別虐待它. + +額外附贈一個 `const double PI = 3.141592653589......` + +''' + +=== meow:: *Usage* (C++ Class) +.Description +`Usage` 是用來分析argc, argv和輸出usage document的class. +argc, argv的部份, 有以下規則 + +* `-c` 其中 `c` 可以代換成正常的一個字元的字符, +這種選像要嘛就是 *有設置* , 不然就是 *沒設置* +* `-c <value>` 附加一個value, 這種選項可以是選擇性 ,即要設定與否都可以, +反之則一定要設定. 另外可以給定value的預設值以及哪些value是可接受的 +* `<value>` 其他, 一律視為process arguments + +.Methods +* `Usage(String const& _name)` + +建構子, 所有說明文字中 *<name>* 都會被代換成 `_name` +* `Usage()` + +建構子, `_name` 自動取為 " *nobody* " +* `import(Usage const& usage)` + +將另一個usage的設定匯入, 回傳成功與否 *(bool)* +* `update(Usage const& usage)` + +將另一個usage分析argc,argv出來的資料拿來用, 回傳成功與否 *(bool)* +* `addOption(unsigned char option, String const& description)` + +新增一個不接額外選項的參數, 並附上說明文字, 回傳成功與否 *(bool)* +* `addOption(unsigned char option, String const& description, +String const& value_type, String const& value_default, bool must)` + +新增一個有額外選項的參數, 並附上說明文字, 額外選項的型別跟預設值. +說明文字中所有的" *<types>* "將會被取代指定的型別, 其中 `must` 代表 +" *是否一定要設定此參數* " , 回傳表成功與否 *(bool)* +* `addOptionValueAccept(unsigned char option, +String const& value, String const& description)` + +針對某個option, 新增一個可接受的額外選項 (如果某個option從頭到尾都沒有 +新增可接受的選項, 則視為不限制), 回傳成功與否 *(bool)* +* `hasOptionSetup(unsigned char option)` + +回傳是否有此選項 *(bool)* +* `getOptionValuesCount(unsigned char option)` + +回傳此參數被設置了幾次 *(size_t)* , 只對有接額外參數的有效 +* `getOptionValue(unsigned char option, size_t index)` + +回傳第`index`個額外選項 *(String)* +* `getProcArgsCount()` + +回傳有多少個Process Arguments *(size_t)* +* `getProcArg(size_t index)` + +取得第`index`個Process Argument *(String)* +* `getProcArgs()` + +回傳一個陣列, 包含所有Process Arguments *(Strings)* +* `addUsageBegin(String const& des)` + +新增一段usage document於每個選項逐條說明之前 +* `addUsageEnd (String const& des)` + +新增一段usage document於每個選項逐條說明之後 +* `String getUsage()` + +回傳usage document *(String)* +* `setArguments(int argc, char** argv, String* errmsg)` + +輸入argv, argc, 回傳是否沒有錯誤發生 *(bool)* , 其中如果有錯誤發生, +且 `errmsg != NULL` 則會將錯誤訊息寫入之 + +NOTE: `String` 是 `std::string` . + +`Strings` 是 `std::vector< std::string> >`. + +如果沒有寫回傳什麼, 就是回傳 `void` + +''' + +=== meow:: *ImplementInterface/RegisterInterface* (C++ Class) .Description -MergeableHeap is a kind of maximum-heap with an extra method `merge`, -which will merge another MergeableHeap into itself. +Assume there is a problem which can be solved by different algorithms. +Then you can write multiple classes to approach this problem. + +Now if you want to decide which algorithm to use in runtime, you can just +approach this case by a simple way: + +* Let all the problem-solving classes inherit from +`class ImplementInterface<T>` , and call the constructure with giving +`identify` (type `T` ) . +* Create an object, type `RegisterInterface<T>` , and register all your +implement class to it by call `regImplement(pointer to the class)`. +* Select which implement class you want by call `getImplement(identify)` , +which will return the pointer to the corresponding class. + +''' + +=== meow:: *DisjointSet* (C++ class) +.Description +`DisjointSet` is a lighting data structure that maintain N numbers from +*0* to *N-1* with methods below: + +[options="header",width="100%",cols="1>,1<s,5<,1<,1<,10<",grid="rows"] +|======================================================================= +|Const?|Name| Parameters| Return Type| Time Complexity| Description +|const|root|(size_t number)|size_t|very fast| +Return the *group id* of the number given +|const|size|()|size_t|very fast| +Return *N* +||reset|(size_t N)|void|very fast| +Clean and initalize +||merge|(size_t number1, + +size_t number2)|size_t|very fast| +*Union* the group contains number1 and the group contains number2. +Return the merged group id +|======================================================================= +NOTE: *very fast* means that you can consider it as constant time. + +''' + +=== meow:: *MergeableHeap<Key, Value>* (C++ class) +.Description +MergeableHeap is a kind of maximum-heap with a special method `merge`, +which will merge another MergeableHeap into itself in O(logN) time. + +.Template Request +* `Key` should has `operator<` .Support methods * N <- number of elements in the heap * M <- number of elements in the other heap if need -[options="header",width="100%",cols="1>,1<s,5<,1<,1<,10<",grid="rows"] +[options="header",width="100%",cols="1>,1<s,3<,1<,1<,10<",grid="rows"] |======================================================================= |Const?|Name| Parameters| Return Type| Time Complexity| Description ||operator= | (MergeableHeap const&)| *this | O(N) @@ -31,7 +219,162 @@ which will merge another MergeableHeap into itself. | Delete all elements from the heap |======================================================================= -WARNING: Consider there are two MergeableHeap `A` and `B`. -`B` will become empty after you call `A.merge(&B)`. +WARNING: Consider there are two MergeableHeap `A` and `B`. + +`B` will become empty after you call `A.merge(&B)`. + The data in `B` will override by data in `A` and `A` will become empty after you call `A.moveTo(&B)` + +''' + +=== meow:: *KD_Tree<Keys, Key, Value>* (C++ class) +.Description +`KD_Tree` is *K-dimension tree*, which is a dictionary(key->value). +Where the type if key is a *K-dimension vector* . + +.Template Request +* `Keys` should has `operator[]` to allow the KD_Tree access the k-dimensions +* `Key` should has `operator*`, `operator+` + +.Support Methods +* N <- numbers of element in the kd-tree +* K <- dimensions +* `Keys` is the tyepname of the vector +* `Key` is the typename of the element in the vector +* `Value` is the typename of value +[options="header",width="100%",cols="1>,1<s,5<,1<,2<,10<",grid="rows"] +|======================================================================= +|Const?|Name| Parameters| Return Type| Time Complexity| Description +|const|root|(size_t number)|size_t|very fast| +||insert|(Key const& k, Value v)|void|O(1)|Insert a pair (k->v) +|| build|()|void|O(KN logN) | Build the data structure(the `insert()` +method will not build the data structure immediately) +|const|query|(Keys const& point, int k)|Value|O(kN ^1-1/k^ ) | +Using Euclidean-Distance to find the k-nearest neighbor from `point` . +And return the corrosponding value +|const|query|(Keys const& point, int k)|std::vector<Value>|O(kN ^1-1/k^ ) | +Using Euclidean-Distance to find all the x-nearest neighbor from `point` , +where x <= k. And return an array of all the corrosponding value. +||clear|()|O(1)|Clear all data +||reset|(size_t dimension)|O(1)|Clear all data and then +set the this->dimension be `dimension` +|======================================================================= +NOTE: O(kN ^1-1/k^ ) is reference from wiki. + +`query()` and `rangeQuery()` will run `build()` first if you called `insert()` +before call them. And `build()` is very slow, so you should not use this class +as a dynamic tree + +''' + +=== meow:: *SplayTree<Key, Value>* (C++ class) +.Description +Like `std::map`, `SplayTree` is an dictionary(key->value). But it has +some extra method, such as `split()`, `merge()`, `keyOffset()`. + +.Data Type +* `Key` is the tyepname of the key +* `Value` is the typename of value +* `SplayTree<Key, Value>:: *Element* ` is a typename which contain +(key->value). It has some methods below: +** `->first ` a constant reference to `Key` +** `->second` a reference to `Value` +** `operator==, operator!=` compare function, check if the two `Element` +is pointer to the same (key->value) + +.Template Request +* `Key` should has `operator<`, `operator+` + +.Support Methods +* N <- numbers of element in the SplayTree +* M <- numbers of element in another SplayTree +[options="header",width="100%",cols="1>,1<s,5<,1<,3^,10<",grid="rows"] +|======================================================================= +|Const?|Name| Parameters| Return Type| Time Complexity| Description +||operator=|(SplayTree const&)| *this | O(N) | copy operator +||moveTo|(SplayTree* t)|void|O(M)| Transform the data in this to `t` +|const|lowerBound|(Key k)|Element|O(logN)| Find the smallest (key->value) +which `k <= key` and return +|const|upperBound|(Key k)|Element|O(logN)| Find the smallest (key->value) +which `k < key` and return +|const|rLowerBound|(Key k)|Element|O(logN)| Find the largest (key->value) +which `key <= k` and return +|const|rUpperBound|(Key k)|Element|O(logN)| Find the largest (key->value) +which `key < k` and return +|const| find|(Key k)|Element|O(logN)| Find the element (key->value) which +`key == k` and return +|const|order|(size_t k)|Element|O(logN)| Find the `k`-th small element. +note that `k` start from zero like a normal C/C++ array. +|const|first|()|Element|O(logN)| Return the smallest element +|const|last|()|Element|O(logN)| Return the largest element +|const|end|()|Element|O(1)|Return an empty element(it can be use to +check if `find()` is successful) +|const|size|()|size_t|O(1)| Return number of elements in the tree +|const|empty|()|bool|O(1)|Return whether the tree is empty +||clear|()|void|O(N)|Clear +||keyOffset|(Key offset)|void|O(1)| Let all the keys in the tree +plus offset +||insert|(Key k, Value v)|bool | O(logN)| Insert an element. +If the tree already has an element with same key, return `false`. +||erase|(Key k)|bool | O(logN)|Erase an element from the tree with +given key. Return `false` if the element not found. +||operator[]|(Key k)|Value|O(logN)|Like `find()` , but it will insert an element +automatic if the corrosponding element not found +||splitOut|(Key const& upper_bound, + +SplayTree* out)|void | O(log N) | Split out all the elements with key +larger than `upper_bound` and store then into `out` +||mergeAfter|(SplayTree* t)|bool|O(logN + logM)|If not all of the elements in this +are smaller than elements in `t`, return `false` , else merge `t` into +itself and return `true`. +||merge|(SplayTree* t)|bool|O(logN + logM)|If all of the elements in this +are smaller than elements in `t` or all of the elements in this larger than +elements in `t` , merge `t` into itself and return `true`. +Else return `false` +|======================================================================= +WARNING: Consider there are two SplayTree `A` and `B`. + +`B` will become empty after you call `A.mergeAfter(&B)` +or `A.merge(&B)` successful. + +The data in `B` will override by data in `A` and `A` will become empty after +you call `A.moveTo(&B)` + +''' + +=== meow:: *SegmentTree<Value>* (C++ class) +.Description +`SegmentTree` is a data structure that can maintain an array, and +support *range update* , *range query* + +.Template Request +* `Value` should has +** `operator+(Value)` offset +** `operator|(Value)` merge two nodes +** `operator*(size_t)` ?? + +For example, if you want to maintain *range minimum* + +* `Value::operator+(Value v2)` will be `this->realValue + v2.realValue` +* `Value::operator|(Value v2)` will be `std::min(this->realValue, v2.realValue)` +* `Value::operator*(size_t n)` will be `this->realValue` + +If you want to maintain *range sum* + +* `Value::operator+(Value v2)` will be `this->realValue + v2.realValue` +* `Value::operator|(Value v2)` will be `this->realValue + v2.realValue)` +* `Value::operator*(size_t n)` will be `this->realValue * n` + +.Support methods +* N <- array size +[options="header",width="100%",cols="1>,1<s,3<,1<,1<,10<",grid="rows"] +|======================================================================= +|Const?|Name| Parameters| Return Type| Time Complexity| Description +||reset|(size_t N)|void|O(1)| +Clear and reset the array size to N (from `0` to `N - 1`) +|const|query|(ssize_t __first, ssize_t __last)|Value|O(logN)| +Range query +||override|(ssize_t __first, ssize_t __last, Value const& __value)|void| +O(logN)| Let the element in the array index from `__first` to `__last` +be `__value` +||offset|(ssize_t __first, ssize_t __last, Value const& __value)|void| +O(logN)| Let the element in the array index from `__first` to `__last` +plus `__value` +|======================================================================= + +''' diff --git a/README.html b/README.html new file mode 100644 index 0000000..4e6b65d --- /dev/null +++ b/README.html @@ -0,0 +1,1845 @@ +<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<meta name="generator" content="AsciiDoc 8.6.7">
+<title>meow</title>
+<style type="text/css">
+/*
+ * AsciiDoc 'volnitsky' theme for xhtml11 and html5 backends.
+ * Based on css from http://volnitsky.com, which was in turn based on default
+ * theme from AsciiDoc
+ *
+ * FIXME: The styling is still a bit rough in places.
+ *
+ */
+
+/* Default font. */
+body {
+ font-family: Georgia,"Times New Roman",Times,serif;
+}
+
+/* Title font. */
+h1, h2, h3, h4, h5, h6,
+div.title, caption.title,
+thead, p.table.header,
+#toctitle,
+#author, #revnumber, #revdate, #revremark,
+#footer {
+ font-family: Candara,Arial,sans-serif;
+}
+
+
+#toc a {
+ border-bottom: 1px dotted #999999;
+ color: #3A3A4D !important;
+ text-decoration: none !important;
+}
+#toc a:hover {
+ border-bottom: 1px solid #6D4100;
+ color: #6D4100 !important;
+ text-decoration: none !important;
+}
+a { color: #666688; text-decoration: none; border-bottom: 1px dotted #666688; }
+a:visited { color: #615FA0; border-bottom: 1px dotted #615FA0; }
+a:hover { color: #6D4100; border-bottom: 1px solid #6D4100; }
+
+em {
+ font-style: italic;
+ color: #444466;
+}
+
+strong {
+ font-weight: bold;
+ color: #444466;
+}
+
+h1, h2, h3, h4, h5, h6 {
+ color: #666688;
+ margin-bottom: 0.5em;
+ line-height: 1.3;
+ letter-spacing:+0.15em;
+}
+
+h1, h2, h3 { border-bottom: 2px solid #ccd; }
+h2 { padding-top: 0.5em; }
+h3 { float: left; }
+h3 + * { clear: left; }
+
+div.sectionbody {
+ margin-left: 0;
+}
+
+hr {
+ border: 1px solid #444466;
+}
+
+p {
+ margin-top: 0.5em;
+ margin-bottom: 0.5em;
+}
+
+ul, ol, li > p {
+ margin-top: 0;
+}
+
+pre {
+ padding: 0;
+ margin: 0;
+}
+
+#author {
+ color: #444466;
+ font-weight: bold;
+ font-size: 1.1em;
+}
+
+#footer {
+ font-size: small;
+ border-top: 2px solid silver;
+ padding-top: 0.5em;
+ margin-top: 4.0em;
+}
+
+#footer-text {
+ float: left;
+ padding-bottom: 0.5em;
+}
+
+#footer-badges {
+ float: right;
+ padding-bottom: 0.5em;
+}
+
+#preamble {
+ margin-top: 1.5em;
+ margin-bottom: 1.5em;
+}
+
+div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
+div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
+div.admonitionblock {
+ margin-top: 1.5em;
+ margin-bottom: 1.5em;
+}
+
+div.admonitionblock {
+ margin-top: 2.5em;
+ margin-bottom: 2.5em;
+}
+
+div.content { /* Block element content. */
+ padding: 0;
+}
+
+/* Block element titles. */
+div.title, caption.title {
+ color: #444466;
+ font-weight: bold;
+ text-align: left;
+ margin-top: 1.0em;
+ margin-bottom: 0.5em;
+}
+div.title + * {
+ margin-top: 0;
+}
+
+td div.title:first-child {
+ margin-top: 0.0em;
+}
+div.content div.title:first-child {
+ margin-top: 0.0em;
+}
+div.content + div.title {
+ margin-top: 0.0em;
+}
+
+div.sidebarblock > div.content {
+ background: #ffffee;
+ border: 1px solid silver;
+ padding: 0.5em;
+}
+
+div.listingblock > div.content {
+ border: 1px solid silver;
+ background: #f4f4f4;
+ padding: 0.5em;
+}
+
+div.quoteblock {
+ padding-left: 2.0em;
+ margin-right: 10%;
+}
+div.quoteblock > div.attribution {
+ padding-top: 0.5em;
+ text-align: right;
+}
+
+div.verseblock {
+ padding-left: 2.0em;
+ margin-right: 10%;
+}
+div.verseblock > pre.content {
+ font-family: inherit;
+}
+div.verseblock > div.attribution {
+ padding-top: 0.75em;
+ text-align: left;
+}
+/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
+div.verseblock + div.attribution {
+ text-align: left;
+}
+
+div.admonitionblock .icon {
+ vertical-align: top;
+ font-size: 1.1em;
+ font-weight: bold;
+ text-decoration: underline;
+ color: #444466;
+ padding-right: 0.5em;
+}
+div.admonitionblock td.content {
+ padding-left: 0.5em;
+ border-left: 2px solid silver;
+}
+
+div.exampleblock > div.content {
+ border-left: 2px solid silver;
+ padding: 0.5em;
+}
+
+div.imageblock div.content { padding-left: 0; }
+span.image img { border-style: none; }
+a.image:visited { color: white; }
+
+dl {
+ margin-top: 0.8em;
+ margin-bottom: 0.8em;
+}
+dt {
+ margin-top: 0.5em;
+ margin-bottom: 0;
+ font-style: normal;
+ color: #444466;
+}
+dd > *:first-child {
+ margin-top: 0.1em;
+}
+
+ul, ol {
+ list-style-position: outside;
+}
+ol.arabic {
+ list-style-type: decimal;
+}
+ol.loweralpha {
+ list-style-type: lower-alpha;
+}
+ol.upperalpha {
+ list-style-type: upper-alpha;
+}
+ol.lowerroman {
+ list-style-type: lower-roman;
+}
+ol.upperroman {
+ list-style-type: upper-roman;
+}
+
+div.compact ul, div.compact ol,
+div.compact p, div.compact p,
+div.compact div, div.compact div {
+ margin-top: 0.1em;
+ margin-bottom: 0.1em;
+}
+
+div.tableblock > table {
+ border: 3px solid #444466;
+}
+thead {
+ font-weight: bold;
+ color: #444466;
+}
+tfoot {
+ font-weight: bold;
+}
+td > div.verse {
+ white-space: pre;
+}
+p.table {
+ margin-top: 0;
+}
+/* Because the table frame attribute is overriden by CSS in most browsers. */
+div.tableblock > table[frame="void"] {
+ border-style: none;
+}
+div.tableblock > table[frame="hsides"] {
+ border-left-style: none;
+ border-right-style: none;
+}
+div.tableblock > table[frame="vsides"] {
+ border-top-style: none;
+ border-bottom-style: none;
+}
+
+
+div.hdlist {
+ margin-top: 0.8em;
+ margin-bottom: 0.8em;
+}
+div.hdlist tr {
+ padding-bottom: 15px;
+}
+dt.hdlist1.strong, td.hdlist1.strong {
+ font-weight: bold;
+}
+td.hdlist1 {
+ vertical-align: top;
+ font-style: normal;
+ padding-right: 0.8em;
+ color: #444466;
+}
+td.hdlist2 {
+ vertical-align: top;
+}
+div.hdlist.compact tr {
+ margin: 0;
+ padding-bottom: 0;
+}
+
+.comment {
+ background: yellow;
+}
+
+@media print {
+ #footer-badges { display: none; }
+}
+
+#toctitle {
+ color: #666688;
+ font-size: 1.2em;
+ font-weight: bold;
+ margin-top: 1.0em;
+ margin-bottom: 0.1em;
+}
+
+div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { margin-top: 0; margin-bottom: 0; }
+div.toclevel1 { margin-top: 0.3em; margin-left: 0; font-size: 1.0em; }
+div.toclevel2 { margin-top: 0.25em; margin-left: 2em; font-size: 0.9em; }
+div.toclevel3 { margin-left: 4em; font-size: 0.8em; }
+div.toclevel4 { margin-left: 6em; font-size: 0.8em; }
+
+body {
+ margin: 1em 5%;
+ max-width: 55em;
+ padding-left: 0;
+
+}
+
+.monospaced, tt, div.listingblock > div.content {
+ font-family: Consolas, "Andale Mono", "Courier New", monospace;
+ color: #004400;
+ background: #e4e4e4;
+ max-width: 80em;
+ line-height: 1.2em;
+ border-radius: 4px;
+ -moz-border-radius: 4px;
+ -webkit-border-radius: 4px;
+}
+
+.paragraph p {
+ line-height: 1.5em;
+ margin-top: 1em;
+}
+
+.paragraph p, li, dd, .content { max-width: 90%; }
+.admonitionblock { max-width: 85%; }
+
+div.sectionbody div.ulist > ul > li {
+ list-style-type: square;
+ color: #aaa;
+}
+ div.sectionbody div.ulist > ul > li > * {
+ color: black;
+ /*font-size: 50%;*/
+ }
+
+
+div.sectionbody div.ulist > ul > li div.ulist > ul > li {
+ color: #ccd ;
+}
+ div.sectionbody div.ulist > ul > li div.ulist > ul > li > * {
+ color: black ;
+ }
+
+em {
+ font-style: normal ! important;
+ font-weight: bold ! important;
+ color: #662222 ! important;
+ letter-spacing:+0.08em ! important;
+}
+
+
+/*
+ * html5 specific
+ *
+ * */
+
+table.tableblock {
+ margin-top: 1.0em;
+ margin-bottom: 1.5em;
+}
+thead, p.tableblock.header {
+ font-weight: bold;
+ color: #666688;
+}
+p.tableblock {
+ margin-top: 0;
+}
+table.tableblock {
+ border-width: 3px;
+ border-spacing: 0px;
+ border-style: solid;
+ border-color: #444466;
+ border-collapse: collapse;
+}
+th.tableblock, td.tableblock {
+ border-width: 1px;
+ padding: 4px;
+ border-style: solid;
+ border-color: #444466;
+}
+
+table.tableblock.frame-topbot {
+ border-left-style: hidden;
+ border-right-style: hidden;
+}
+table.tableblock.frame-sides {
+ border-top-style: hidden;
+ border-bottom-style: hidden;
+}
+table.tableblock.frame-none {
+ border-style: hidden;
+}
+
+th.tableblock.halign-left, td.tableblock.halign-left {
+ text-align: left;
+}
+th.tableblock.halign-center, td.tableblock.halign-center {
+ text-align: center;
+}
+th.tableblock.halign-right, td.tableblock.halign-right {
+ text-align: right;
+}
+
+th.tableblock.valign-top, td.tableblock.valign-top {
+ vertical-align: top;
+}
+th.tableblock.valign-middle, td.tableblock.valign-middle {
+ vertical-align: middle;
+}
+th.tableblock.valign-bottom, td.tableblock.valign-bottom {
+ vertical-align: bottom;
+}
+
+
+@media screen {
+ body {
+ max-width: 50em; /* approximately 80 characters wide */
+ margin-left: 16em;
+ }
+
+ #toc {
+ position: fixed;
+ top: 0;
+ left: 0;
+ bottom: 0;
+ width: 13em;
+ padding: 0.5em;
+ padding-bottom: 1.5em;
+ margin: 0;
+ overflow: auto;
+ border-right: 3px solid #f8f8f8;
+ background-color: white;
+ }
+
+ #toc .toclevel1 {
+ margin-top: 0.5em;
+ }
+
+ #toc .toclevel2 {
+ margin-top: 0.25em;
+ display: list-item;
+ color: #aaaaaa;
+ }
+
+ #toctitle {
+ margin-top: 0.5em;
+ }
+}
+</style>
+<script type="text/javascript">
+/*<![CDATA[*/
+var asciidoc = { // Namespace.
+
+/////////////////////////////////////////////////////////////////////
+// Table Of Contents generator
+/////////////////////////////////////////////////////////////////////
+
+/* Author: Mihai Bazon, September 2002
+ * http://students.infoiasi.ro/~mishoo
+ *
+ * Table Of Content generator
+ * Version: 0.4
+ *
+ * Feel free to use this script under the terms of the GNU General Public
+ * License, as long as you do not remove or alter this notice.
+ */
+
+ /* modified by Troy D. Hanson, September 2006. License: GPL */
+ /* modified by Stuart Rackham, 2006, 2009. License: GPL */
+
+// toclevels = 1..4.
+toc: function (toclevels) {
+
+ function getText(el) {
+ var text = "";
+ for (var i = el.firstChild; i != null; i = i.nextSibling) {
+ if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
+ text += i.data;
+ else if (i.firstChild != null)
+ text += getText(i);
+ }
+ return text;
+ }
+
+ function TocEntry(el, text, toclevel) {
+ this.element = el;
+ this.text = text;
+ this.toclevel = toclevel;
+ }
+
+ function tocEntries(el, toclevels) {
+ var result = new Array;
+ var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
+ // Function that scans the DOM tree for header elements (the DOM2
+ // nodeIterator API would be a better technique but not supported by all
+ // browsers).
+ var iterate = function (el) {
+ for (var i = el.firstChild; i != null; i = i.nextSibling) {
+ if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
+ var mo = re.exec(i.tagName);
+ if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
+ result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
+ }
+ iterate(i);
+ }
+ }
+ }
+ iterate(el);
+ return result;
+ }
+
+ var toc = document.getElementById("toc");
+ if (!toc) {
+ return;
+ }
+
+ // Delete existing TOC entries in case we're reloading the TOC.
+ var tocEntriesToRemove = [];
+ var i;
+ for (i = 0; i < toc.childNodes.length; i++) {
+ var entry = toc.childNodes[i];
+ if (entry.nodeName.toLowerCase() == 'div'
+ && entry.getAttribute("class")
+ && entry.getAttribute("class").match(/^toclevel/))
+ tocEntriesToRemove.push(entry);
+ }
+ for (i = 0; i < tocEntriesToRemove.length; i++) {
+ toc.removeChild(tocEntriesToRemove[i]);
+ }
+
+ // Rebuild TOC entries.
+ var entries = tocEntries(document.getElementById("content"), toclevels);
+ for (var i = 0; i < entries.length; ++i) {
+ var entry = entries[i];
+ if (entry.element.id == "")
+ entry.element.id = "_toc_" + i;
+ var a = document.createElement("a");
+ a.href = "#" + entry.element.id;
+ a.appendChild(document.createTextNode(entry.text));
+ var div = document.createElement("div");
+ div.appendChild(a);
+ div.className = "toclevel" + entry.toclevel;
+ toc.appendChild(div);
+ }
+ if (entries.length == 0)
+ toc.parentNode.removeChild(toc);
+},
+
+
+/////////////////////////////////////////////////////////////////////
+// Footnotes generator
+/////////////////////////////////////////////////////////////////////
+
+/* Based on footnote generation code from:
+ * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
+ */
+
+footnotes: function () {
+ // Delete existing footnote entries in case we're reloading the footnodes.
+ var i;
+ var noteholder = document.getElementById("footnotes");
+ if (!noteholder) {
+ return;
+ }
+ var entriesToRemove = [];
+ for (i = 0; i < noteholder.childNodes.length; i++) {
+ var entry = noteholder.childNodes[i];
+ if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
+ entriesToRemove.push(entry);
+ }
+ for (i = 0; i < entriesToRemove.length; i++) {
+ noteholder.removeChild(entriesToRemove[i]);
+ }
+
+ // Rebuild footnote entries.
+ var cont = document.getElementById("content");
+ var spans = cont.getElementsByTagName("span");
+ var refs = {};
+ var n = 0;
+ for (i=0; i<spans.length; i++) {
+ if (spans[i].className == "footnote") {
+ n++;
+ var note = spans[i].getAttribute("data-note");
+ if (!note) {
+ // Use [\s\S] in place of . so multi-line matches work.
+ // Because JavaScript has no s (dotall) regex flag.
+ note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
+ spans[i].innerHTML =
+ "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
+ "' title='View footnote' class='footnote'>" + n + "</a>]";
+ spans[i].setAttribute("data-note", note);
+ }
+ noteholder.innerHTML +=
+ "<div class='footnote' id='_footnote_" + n + "'>" +
+ "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
+ n + "</a>. " + note + "</div>";
+ var id =spans[i].getAttribute("id");
+ if (id != null) refs["#"+id] = n;
+ }
+ }
+ if (n == 0)
+ noteholder.parentNode.removeChild(noteholder);
+ else {
+ // Process footnoterefs.
+ for (i=0; i<spans.length; i++) {
+ if (spans[i].className == "footnoteref") {
+ var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
+ href = href.match(/#.*/)[0]; // Because IE return full URL.
+ n = refs[href];
+ spans[i].innerHTML =
+ "[<a href='#_footnote_" + n +
+ "' title='View footnote' class='footnote'>" + n + "</a>]";
+ }
+ }
+ }
+},
+
+install: function(toclevels) {
+ var timerId;
+
+ function reinstall() {
+ asciidoc.footnotes();
+ if (toclevels) {
+ asciidoc.toc(toclevels);
+ }
+ }
+
+ function reinstallAndRemoveTimer() {
+ clearInterval(timerId);
+ reinstall();
+ }
+
+ timerId = setInterval(reinstall, 500);
+ if (document.addEventListener)
+ document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
+ else
+ window.onload = reinstallAndRemoveTimer;
+}
+
+}
+asciidoc.install(2);
+/*]]>*/
+</script>
+</head>
+<body class="article" style="max-width:70em">
+<div id="header">
+<h1>meow</h1>
+<div id="toc"> + <div id="toctitle">Table of Contents</div> + <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript> +</div>
+</div>
+<div id="content">
+<div class="sect1">
+<h2 id="_description">Description</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>一個不需要, 也不建議先compile成obj files的templates.</p></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<div class="title">Tip</div>
+</td>
+<td class="content"><strong>README.html</strong> is more beautiful.</td>
+</tr></table>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_file_tree">File Tree</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_strong_meowpp_strong_c_templates"><strong>meowpp/</strong> C++ templates</h3>
+<div class="ulist"><ul>
+<li>
+<p>
+<strong>utility.h</strong> some useful functions,
+ <span class="monospaced">stringPringf()</span> , <span class="monospaced">stringReplace</span> , <span class="monospaced">cstringEndWith</span> ,
+ <span class="monospaced">debugPrintf()</span> , <span class="monospaced">messagePrintf()</span> , <span class="monospaced">constant PI</span> ,
+ <span class="monospaced">noEPS()</span> , <span class="monospaced">normalize()</span> , <span class="monospaced">denormalize</span> ,
+ <span class="monospaced">ratioMapping</span> , <span class="monospaced">inRange()</span> , <span class="monospaced">squ()</span> , <span class="monospaced">average()</span>
+</p>
+</li>
+<li>
+<p>
+<strong>Usage.h</strong> <span class="monospaced">class Usage</span>
+</p>
+</li>
+<li>
+<p>
+<strong>colors/</strong> Color splces and transformer
+</p>
+<div class="ulist"><ul>
+<li>
+<p>
+<strong>RGB.h</strong> <span class="monospaced">class RGBi</span> , <span class="monospaced">class RGBf</span>
+</p>
+</li>
+<li>
+<p>
+<strong>YUV.h</strong> <span class="monospaced">class YUVi</span> , <span class="monospaced">class YUVf</span> , <span class="monospaced">RGB_to_YUV()</span> , <span class="monospaced">YUV_to_RGB</span>
+</p>
+</li>
+<li>
+<p>
+<strong>HSL.h</strong> <span class="monospaced">class HSLf</span> , <span class="monospaced">RGB_to_HSL()</span> , <span class="monospaced">HSL_to_RGB</span> ,
+ <span class="monospaced">YUV_to_HSL()</span> , <span class="monospaced">HSL_to_YUV</span>
+</p>
+</li>
+<li>
+<p>
+<strong>HSV.h</strong> <span class="monospaced">class HSVf</span> , <span class="monospaced">RGB_to_HSV()</span> , <span class="monospaced">HSV_to_RGB</span> ,
+ <span class="monospaced">YUV_to_HSV()</span> , <span class="monospaced">HSV_to_YUV</span> ,
+ <span class="monospaced">HSL_to_HSV()</span> , <span class="monospaced">HSV_to_HSL</span>
+</p>
+</li>
+</ul></div>
+</li>
+<li>
+<p>
+<strong>dsa/</strong> Data Structures and Algorithms
+</p>
+<div class="ulist"><ul>
+<li>
+<p>
+<strong>DisjointSet.h</strong> <span class="monospaced">class DisjointSet</span>
+</p>
+</li>
+<li>
+<p>
+<strong>Heaps.h</strong> <span class="monospaced">class MergeableHeap</span>
+</p>
+</li>
+<li>
+<p>
+<strong>KD_Tree.h</strong> <span class="monospaced">class KD_Tree</span>
+</p>
+</li>
+<li>
+<p>
+<strong>SplayTree.h</strong> <span class="monospaced">class SplayTree</span>
+</p>
+</li>
+</ul></div>
+</li>
+<li>
+<p>
+<strong>oo/</strong>
+</p>
+<div class="ulist"><ul>
+<li>
+<p>
+<strong>Register_Implement.h</strong> <span class="monospaced">class RegisterInterface</span> ,
+ <span class="monospaced">class ImplementInterface</span>
+</p>
+</li>
+</ul></div>
+</li>
+</ul></div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_structures_classes_functions">Structures/Classes/Functions</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_meow_strong_functios_strong_in_utility_h">meow:: <strong>Functios</strong> in utility.h</h3>
+<table class="tableblock frame-all grid-rows"
+style="
+width:100%;
+">
+<col style="width:5%;">
+<col style="width:29%;">
+<col style="width:5%;">
+<col style="width:58%;">
+<thead>
+<tr>
+<th class="tableblock halign-right valign-top" >Name </th>
+<th class="tableblock halign-left valign-top" > Parameters </th>
+<th class="tableblock halign-left valign-top" > Return Type </th>
+<th class="tableblock halign-left valign-top" > Description</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"><strong>stringPrintf</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(char const * fmt, …)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">std::string</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Format print to C++ string and return it</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"><strong>stringReplace</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(std::string str,<br>
+std::string const& from,<br>
+std::string const& to)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">std::string</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Return a string like <span class="monospaced">str</span>, but all <span class="monospaced">from</span> be replaced by <span class="monospaced">to</span></p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"><strong>cstringEndWith</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(char const* str, int n, …)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">bool</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Return whether <span class="monospaced">str</span> is end with one of the c-string you specify in
+the parameters or not</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"><strong>debugPrintf</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(char const* fmt, …)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">void</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Print debug message (file name, line number, …etc) when <span class="monospaced">DEBUG</span> is
+defined</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"><strong>messagePrintf</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(int level_change, char const* fmt, …)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">void</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">階層式的訊息輸出</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"><strong>noEPS</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(double value, double eps = 1e-9)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">double</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">如果abs(輸入的數值) < eps, 則回傳0, 否則回傳輸入的數值</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"><strong>normalize</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(double lower, double upper,<br>
+double value)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">double</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(value - lower) / (upper - lower)</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"><strong>denormalize</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(double lower, double upper,<br>
+double ratio)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">double</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">lower + (upper - lower) * ratio</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"><strong>ratioMapping</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(double l1, double u1,<br>
+double m1, double l2,<br>
+double u2)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">double</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">denormalize(l2, u2, normalize(l1, u1, m1))</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"><strong>inRange<T></strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(T const& mn, T const& mx,<br>
+T const& v)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">T</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">std::max(mn, std::min(mx, v))</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"><strong>squ<T></strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(T const& x)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">T</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">x * x</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"><strong>average<T></strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(T const& beg, T const& end,<br>
+double sigs)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">T</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">只將 <span class="monospaced">sigs</span> 個標準差以內的數據拿來取平均</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"><strong>average<T></strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(T const& beg, T const& end,<br>
+T const& p, double sigs)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">T</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">同上, 不過這次用 <span class="monospaced">p</span> 來加權平均</p></td>
+</tr>
+</tbody>
+</table>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content"><span class="monospaced">stringReplace()</span> 不是用什麼好方法寫的因此執行效率很低請別虐待它.<br>
+額外附贈一個 <span class="monospaced">const double PI = 3.141592653589......</span></td>
+</tr></table>
+</div>
+<hr>
+</div>
+<div class="sect2">
+<h3 id="_meow_strong_usage_strong_c_class">meow:: <strong>Usage</strong> (C++ Class)</h3>
+<div class="paragraph"><div class="title">Description</div><p><span class="monospaced">Usage</span> 是用來分析argc, argv和輸出usage document的class.
+argc, argv的部份, 有以下規則</p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+<span class="monospaced">-c</span> 其中 <span class="monospaced">c</span> 可以代換成正常的一個字元的字符,
+這種選像要嘛就是 <strong>有設置</strong> , 不然就是 <strong>沒設置</strong>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">-c <value></span> 附加一個value, 這種選項可以是選擇性 ,即要設定與否都可以,
+反之則一定要設定. 另外可以給定value的預設值以及哪些value是可接受的
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced"><value></span> 其他, 一律視為process arguments
+</p>
+</li>
+</ul></div>
+<div class="ulist"><div class="title">Methods</div><ul>
+<li>
+<p>
+<span class="monospaced">Usage(String const& _name)</span><br>
+建構子, 所有說明文字中 <strong><name></strong> 都會被代換成 <span class="monospaced">_name</span>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">Usage()</span><br>
+建構子, <span class="monospaced">_name</span> 自動取為 " <strong>nobody</strong> "
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">import(Usage const& usage)</span><br>
+將另一個usage的設定匯入, 回傳成功與否 <strong>(bool)</strong>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">update(Usage const& usage)</span><br>
+將另一個usage分析argc,argv出來的資料拿來用, 回傳成功與否 <strong>(bool)</strong>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">addOption(unsigned char option, String const& description)</span><br>
+新增一個不接額外選項的參數, 並附上說明文字, 回傳成功與否 <strong>(bool)</strong>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">addOption(unsigned char option, String const& description,
+String const& value_type, String const& value_default, bool must)</span><br>
+新增一個有額外選項的參數, 並附上說明文字, 額外選項的型別跟預設值.
+說明文字中所有的" <strong><types></strong> "將會被取代指定的型別, 其中 <span class="monospaced">must</span> 代表
+" <strong>是否一定要設定此參數</strong> " , 回傳表成功與否 <strong>(bool)</strong>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">addOptionValueAccept(unsigned char option,
+String const& value, String const& description)</span><br>
+針對某個option, 新增一個可接受的額外選項 (如果某個option從頭到尾都沒有
+新增可接受的選項, 則視為不限制), 回傳成功與否 <strong>(bool)</strong>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">hasOptionSetup(unsigned char option)</span><br>
+回傳是否有此選項 <strong>(bool)</strong>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">getOptionValuesCount(unsigned char option)</span><br>
+回傳此參數被設置了幾次 <strong>(size_t)</strong> , 只對有接額外參數的有效
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">getOptionValue(unsigned char option, size_t index)</span><br>
+回傳第`index`個額外選項 <strong>(String)</strong>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">getProcArgsCount()</span><br>
+回傳有多少個Process Arguments <strong>(size_t)</strong>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">getProcArg(size_t index)</span><br>
+取得第`index`個Process Argument <strong>(String)</strong>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">getProcArgs()</span><br>
+回傳一個陣列, 包含所有Process Arguments <strong>(Strings)</strong>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">addUsageBegin(String const& des)</span><br>
+新增一段usage document於每個選項逐條說明之前
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">addUsageEnd (String const& des)</span> <br>
+新增一段usage document於每個選項逐條說明之後
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">String getUsage()</span><br>
+回傳usage document <strong>(String)</strong>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">setArguments(int argc, char** argv, String* errmsg)</span><br>
+輸入argv, argc, 回傳是否沒有錯誤發生 <strong>(bool)</strong> , 其中如果有錯誤發生,
+且 <span class="monospaced">errmsg != NULL</span> 則會將錯誤訊息寫入之
+</p>
+</li>
+</ul></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content"><span class="monospaced">String</span> 是 <span class="monospaced">std::string</span> .<br>
+<span class="monospaced">Strings</span> 是 <span class="monospaced">std::vector< std::string> ></span>.<br>
+如果沒有寫回傳什麼, 就是回傳 <span class="monospaced">void</span></td>
+</tr></table>
+</div>
+<hr>
+</div>
+<div class="sect2">
+<h3 id="_meow_strong_implementinterface_registerinterface_strong_c_class">meow:: <strong>ImplementInterface/RegisterInterface</strong> (C++ Class)</h3>
+<div class="paragraph"><div class="title">Description</div><p>Assume there is a problem which can be solved by different algorithms.
+Then you can write multiple classes to approach this problem.<br>
+Now if you want to decide which algorithm to use in runtime, you can just
+approach this case by a simple way:</p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+Let all the problem-solving classes inherit from
+<span class="monospaced">class ImplementInterface<T></span> , and call the constructure with giving
+<span class="monospaced">identify</span> (type <span class="monospaced">T</span> ) .
+</p>
+</li>
+<li>
+<p>
+Create an object, type <span class="monospaced">RegisterInterface<T></span> , and register all your
+implement class to it by call <span class="monospaced">regImplement(pointer to the class)</span>.
+</p>
+</li>
+<li>
+<p>
+Select which implement class you want by call <span class="monospaced">getImplement(identify)</span> ,
+which will return the pointer to the corresponding class.
+</p>
+</li>
+</ul></div>
+<hr>
+</div>
+<div class="sect2">
+<h3 id="_meow_strong_disjointset_strong_c_class">meow:: <strong>DisjointSet</strong> (C++ class)</h3>
+<div class="paragraph"><div class="title">Description</div><p><span class="monospaced">DisjointSet</span> is a lighting data structure that maintain N numbers from
+<strong>0</strong> to <strong>N-1</strong> with methods below:</p></div>
+<table class="tableblock frame-all grid-rows"
+style="
+width:100%;
+">
+<col style="width:5%;">
+<col style="width:5%;">
+<col style="width:26%;">
+<col style="width:5%;">
+<col style="width:5%;">
+<col style="width:52%;">
+<thead>
+<tr>
+<th class="tableblock halign-right valign-top" >Const?</th>
+<th class="tableblock halign-left valign-top" >Name</th>
+<th class="tableblock halign-left valign-top" > Parameters</th>
+<th class="tableblock halign-left valign-top" > Return Type</th>
+<th class="tableblock halign-left valign-top" > Time Complexity</th>
+<th class="tableblock halign-left valign-top" > Description</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>root</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(size_t number)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">size_t</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">very fast</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Return the <strong>group id</strong> of the number given</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>size</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">()</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">size_t</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">very fast</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Return <strong>N</strong></p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>reset</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(size_t N)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">void</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">very fast</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Clean and initalize</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>merge</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(size_t number1,<br>
+size_t number2)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">size_t</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">very fast</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>Union</strong> the group contains number1 and the group contains number2.
+Return the merged group id</p></td>
+</tr>
+</tbody>
+</table>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content"><strong>very fast</strong> means that you can consider it as constant time.</td>
+</tr></table>
+</div>
+<hr>
+</div>
+<div class="sect2">
+<h3 id="_meow_strong_mergeableheap_lt_key_value_gt_strong_c_class">meow:: <strong>MergeableHeap<Key, Value></strong> (C++ class)</h3>
+<div class="paragraph"><div class="title">Description</div><p>MergeableHeap is a kind of maximum-heap with a special method <span class="monospaced">merge</span>,
+which will merge another MergeableHeap into itself in O(logN) time.</p></div>
+<div class="ulist"><div class="title">Template Request</div><ul>
+<li>
+<p>
+<span class="monospaced">Key</span> should has <span class="monospaced">operator<</span>
+</p>
+</li>
+</ul></div>
+<div class="ulist"><div class="title">Support methods</div><ul>
+<li>
+<p>
+N ← number of elements in the heap
+</p>
+</li>
+<li>
+<p>
+M ← number of elements in the other heap if need
+</p>
+</li>
+</ul></div>
+<table class="tableblock frame-all grid-rows"
+style="
+width:100%;
+">
+<col style="width:5%;">
+<col style="width:5%;">
+<col style="width:17%;">
+<col style="width:5%;">
+<col style="width:5%;">
+<col style="width:58%;">
+<thead>
+<tr>
+<th class="tableblock halign-right valign-top" >Const?</th>
+<th class="tableblock halign-left valign-top" >Name</th>
+<th class="tableblock halign-left valign-top" > Parameters</th>
+<th class="tableblock halign-left valign-top" > Return Type</th>
+<th class="tableblock halign-left valign-top" > Time Complexity</th>
+<th class="tableblock halign-left valign-top" > Description</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>operator=</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(MergeableHeap const&)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">*this</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(N)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Copy operator.</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>moveTo</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(MergeableHeap*)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">void</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(M)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Transform the this→data to the heap specified in parameters</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>top</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">()</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Element</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(1)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Return the maximum element in the heap.</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>size</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">()</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">size_t</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(1)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Return the number of elements in the heap.</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>empty</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">()</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">bool</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(1)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Return whether the heap is empty or not.</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>push</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(Element)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">void</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(log N)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Add a element into the heap</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>pop</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">()</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">void</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(log N)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Delete the maximum element from the heap</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>merge</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(MergeableHeap*)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">void</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(log M)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Merge the specified MergeableHeap(with size=M) into itself</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>clear</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">()</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">void</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(N)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Delete all elements from the heap</p></td>
+</tr>
+</tbody>
+</table>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<div class="title">Warning</div>
+</td>
+<td class="content">Consider there are two MergeableHeap <span class="monospaced">A</span> and <span class="monospaced">B</span>.<br>
+<span class="monospaced">B</span> will become empty after you call <span class="monospaced">A.merge(&B)</span>.<br>
+The data in <span class="monospaced">B</span> will override by data in <span class="monospaced">A</span> and <span class="monospaced">A</span> will become empty after
+you call <span class="monospaced">A.moveTo(&B)</span></td>
+</tr></table>
+</div>
+<hr>
+</div>
+<div class="sect2">
+<h3 id="_meow_strong_kd_tree_lt_keys_key_value_gt_strong_c_class">meow:: <strong>KD_Tree<Keys, Key, Value></strong> (C++ class)</h3>
+<div class="paragraph"><div class="title">Description</div><p><span class="monospaced">KD_Tree</span> is <strong>K-dimension tree</strong>, which is a dictionary(key→value).
+Where the type if key is a <strong>K-dimension vector</strong> .</p></div>
+<div class="ulist"><div class="title">Template Request</div><ul>
+<li>
+<p>
+<span class="monospaced">Keys</span> should has <span class="monospaced">operator[]</span> to allow the KD_Tree access the k-dimensions
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">Key</span> should has <span class="monospaced">operator*</span>, <span class="monospaced">operator+</span>
+</p>
+</li>
+</ul></div>
+<div class="ulist"><div class="title">Support Methods</div><ul>
+<li>
+<p>
+N ← numbers of element in the kd-tree
+</p>
+</li>
+<li>
+<p>
+K ← dimensions
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">Keys</span> is the tyepname of the vector
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">Key</span> is the typename of the element in the vector
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">Value</span> is the typename of value
+</p>
+</li>
+</ul></div>
+<table class="tableblock frame-all grid-rows"
+style="
+width:100%;
+">
+<col style="width:5%;">
+<col style="width:5%;">
+<col style="width:25%;">
+<col style="width:5%;">
+<col style="width:10%;">
+<col style="width:50%;">
+<thead>
+<tr>
+<th class="tableblock halign-right valign-top" >Const?</th>
+<th class="tableblock halign-left valign-top" >Name</th>
+<th class="tableblock halign-left valign-top" > Parameters</th>
+<th class="tableblock halign-left valign-top" > Return Type</th>
+<th class="tableblock halign-left valign-top" > Time Complexity</th>
+<th class="tableblock halign-left valign-top" > Description</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>root</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(size_t number)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">size_t</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">very fast</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>insert</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(Key const& k, Value v)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">void</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(1)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Insert a pair (k→v)</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>build</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">()</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">void</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(KN logN)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Build the data structure(the <span class="monospaced">insert()</span>
+method will not build the data structure immediately)</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>query</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(Keys const& point, int k)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Value</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(kN <sup>1-1/k</sup> )</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Using Euclidean-Distance to find the k-nearest neighbor from <span class="monospaced">point</span> .
+And return the corrosponding value</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>query</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(Keys const& point, int k)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">std::vector<Value></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(kN <sup>1-1/k</sup> )</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Using Euclidean-Distance to find all the x-nearest neighbor from <span class="monospaced">point</span> ,
+where x ⇐ k. And return an array of all the corrosponding value.</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>clear</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">()</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(1)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Clear all data</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
+</tr>
+</tbody>
+</table>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">O(kN <sup>1-1/k</sup> ) is reference from wiki.<br>
+<span class="monospaced">query()</span> and <span class="monospaced">rangeQuery()</span> will run <span class="monospaced">build()</span> first if you called <span class="monospaced">insert()</span>
+before call them. And <span class="monospaced">build()</span> is very slow, so you should not use this class
+as a dynamic tree</td>
+</tr></table>
+</div>
+<hr>
+</div>
+<div class="sect2">
+<h3 id="_meow_strong_splaytree_lt_key_value_gt_strong_c_class">meow:: <strong>SplayTree<Key, Value></strong> (C++ class)</h3>
+<div class="paragraph"><div class="title">Description</div><p>Like <span class="monospaced">std::map</span>, <span class="monospaced">SplayTree</span> is an dictionary(key→value). But it has
+some extra method, such as <span class="monospaced">split()</span>, <span class="monospaced">merge()</span>, <span class="monospaced">keyOffset()</span>.</p></div>
+<div class="ulist"><div class="title">Data Type</div><ul>
+<li>
+<p>
+<span class="monospaced">Key</span> is the tyepname of the key
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">Value</span> is the typename of value
+</p>
+</li>
+<li>
+<p>
+`SplayTree<Key, Value>:: <strong>Element</strong> ` is a typename which contain
+(key→value). It has some methods below:
+</p>
+<div class="ulist"><ul>
+<li>
+<p>
+<span class="monospaced">->first ` a constant reference to `Key</span>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">->second</span> a reference to <span class="monospaced">Value</span>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">operator==, operator!=</span> compare function, check if the two <span class="monospaced">Element</span>
+is pointer to the same (key→value)
+</p>
+</li>
+</ul></div>
+</li>
+</ul></div>
+<div class="ulist"><div class="title">Template Request</div><ul>
+<li>
+<p>
+<span class="monospaced">Key</span> should has <span class="monospaced">operator<</span>, <span class="monospaced">operator+</span>
+</p>
+</li>
+</ul></div>
+<div class="ulist"><div class="title">Support Methods</div><ul>
+<li>
+<p>
+N ← numbers of element in the SplayTree
+</p>
+</li>
+<li>
+<p>
+M ← numbers of element in another SplayTree
+</p>
+</li>
+</ul></div>
+<table class="tableblock frame-all grid-rows"
+style="
+width:100%;
+">
+<col style="width:4%;">
+<col style="width:4%;">
+<col style="width:23%;">
+<col style="width:4%;">
+<col style="width:14%;">
+<col style="width:47%;">
+<thead>
+<tr>
+<th class="tableblock halign-right valign-top" >Const?</th>
+<th class="tableblock halign-left valign-top" >Name</th>
+<th class="tableblock halign-left valign-top" > Parameters</th>
+<th class="tableblock halign-left valign-top" > Return Type</th>
+<th class="tableblock halign-center valign-top" > Time Complexity</th>
+<th class="tableblock halign-left valign-top" > Description</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>operator=</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(SplayTree const&)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">*this</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(N)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">copy operator</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>moveTo</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(SplayTree* t)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">void</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(M)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Transform the data in this to <span class="monospaced">t</span></p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>lowerBound</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(Key k)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Element</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(logN)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Find the smallest (key→value)
+which <span class="monospaced">k <= key</span> and return</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>upperBound</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(Key k)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Element</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(logN)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Find the smallest (key→value)
+which <span class="monospaced">k < key</span> and return</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>rLowerBound</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(Key k)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Element</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(logN)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Find the largest (key→value)
+which <span class="monospaced">key <= k</span> and return</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>rUpperBound</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(Key k)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Element</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(logN)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Find the largest (key→value)
+which <span class="monospaced">key < k</span> and return</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>find</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(Key k)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Element</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(logN)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Find the element (key→value) which
+<span class="monospaced">key == k</span> and return</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>order</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(size_t k)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Element</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(logN)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Find the <span class="monospaced">k</span>-th small element.
+note that <span class="monospaced">k</span> start from zero like a normal C/C++ array.</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>first</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">()</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Element</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(logN)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Return the smallest element</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>last</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">()</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Element</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(logN)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Return the largest element</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>end</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">()</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Element</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(1)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Return an empty element(it can be use to
+check if <span class="monospaced">find()</span> is successful)</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>size</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">()</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">size_t</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(1)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Return number of elements in the tree</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>empty</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">()</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">bool</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(1)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Return whether the tree is empty</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>clear</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">()</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">void</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(N)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Clear</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>keyOffset</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(Key offset)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">void</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(1)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Let all the keys in the tree
+plus offset</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>insert</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(Key k, Value v)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">bool</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(logN)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Insert an element.
+If the tree already has an element with same key, return <span class="monospaced">false</span>.</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>erase</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(Key k)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">bool</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(logN)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Erase an element from the tree with
+given key. Return <span class="monospaced">false</span> if the element not found.</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>operator[]</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(Key k)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Value</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(logN)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Like <span class="monospaced">find()</span> , but it will insert an element
+automatic if the corrosponding element not found</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>splitOut</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(Key const& upper_bound,<br>
+SplayTree* out)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">void</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(log N)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Split out all the elements with key
+larger than <span class="monospaced">upper_bound</span> and store then into <span class="monospaced">out</span></p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>mergeAfter</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(SplayTree* t)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">bool</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(logN + logM)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">If not all of the elements in this
+are smaller than elements in <span class="monospaced">t</span>, return <span class="monospaced">false</span> , else merge <span class="monospaced">t</span> into
+itself and return <span class="monospaced">true</span>.</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>merge</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(SplayTree* t)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">bool</p></td>
+<td class="tableblock halign-center valign-top" ><p class="tableblock">O(logN + logM)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">If all of the elements in this
+are smaller than elements in <span class="monospaced">t</span> or all of the elements in this larger than
+elements in <span class="monospaced">t</span> , merge <span class="monospaced">t</span> into itself and return <span class="monospaced">true</span>.
+Else return <span class="monospaced">false</span></p></td>
+</tr>
+</tbody>
+</table>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<div class="title">Warning</div>
+</td>
+<td class="content">Consider there are two SplayTree <span class="monospaced">A</span> and <span class="monospaced">B</span>.<br>
+<span class="monospaced">B</span> will become empty after you call <span class="monospaced">A.mergeAfter(&B)</span>
+or <span class="monospaced">A.merge(&B)</span> successful.<br>
+The data in <span class="monospaced">B</span> will override by data in <span class="monospaced">A</span> and <span class="monospaced">A</span> will become empty after
+you call <span class="monospaced">A.moveTo(&B)</span></td>
+</tr></table>
+</div>
+<hr>
+</div>
+<div class="sect2">
+<h3 id="_meow_strong_segmenttree_lt_value_gt_strong_c_class">meow:: <strong>SegmentTree<Value></strong> (C++ class)</h3>
+<div class="paragraph"><div class="title">Description</div><p><span class="monospaced">SegmentTree</span> is a data structure that can maintain an array, and
+support <strong>range update</strong> , <strong>range query</strong></p></div>
+<div class="ulist"><div class="title">Template Request</div><ul>
+<li>
+<p>
+<span class="monospaced">Value</span> should has
+</p>
+<div class="ulist"><ul>
+<li>
+<p>
+<span class="monospaced">operator+(Value)</span> offset
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">operator|(Value)</span> merge two nodes
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">operator*(size_t)</span> ??
+</p>
+</li>
+</ul></div>
+</li>
+</ul></div>
+<div class="paragraph"><p>For example, if you want to maintain <strong>range minimum</strong></p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+<span class="monospaced">Value::operator+(Value v2)</span> will be <span class="monospaced">this->realValue + v2.realValue</span>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">Value::operator|(Value v2)</span> will be <span class="monospaced">std::min(this->realValue, v2.realValue)</span>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">Value::operator*(size_t n)</span> will be <span class="monospaced">this->realValue</span>
+</p>
+</li>
+</ul></div>
+<div class="paragraph"><p>If you want to maintain <strong>range sum</strong></p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+<span class="monospaced">Value::operator+(Value v2)</span> will be <span class="monospaced">this->realValue + v2.realValue</span>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">Value::operator|(Value v2)</span> will be <span class="monospaced">this->realValue + v2.realValue)</span>
+</p>
+</li>
+<li>
+<p>
+<span class="monospaced">Value::operator*(size_t n)</span> will be <span class="monospaced">this->realValue * n</span>
+</p>
+</li>
+</ul></div>
+<div class="ulist"><div class="title">Support methods</div><ul>
+<li>
+<p>
+N ← array size
+</p>
+</li>
+</ul></div>
+<table class="tableblock frame-all grid-rows"
+style="
+width:100%;
+">
+<col style="width:5%;">
+<col style="width:5%;">
+<col style="width:17%;">
+<col style="width:5%;">
+<col style="width:5%;">
+<col style="width:58%;">
+<thead>
+<tr>
+<th class="tableblock halign-right valign-top" >Const?</th>
+<th class="tableblock halign-left valign-top" >Name</th>
+<th class="tableblock halign-left valign-top" > Parameters</th>
+<th class="tableblock halign-left valign-top" > Return Type</th>
+<th class="tableblock halign-left valign-top" > Time Complexity</th>
+<th class="tableblock halign-left valign-top" > Description</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>reset</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(size_t N)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">void</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(1)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Clear and reset the array size to N (from <span class="monospaced">0</span> to <span class="monospaced">N - 1</span>)</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock">const</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>query</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(ssize_t <em>first, ssize_t </em>last)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Value</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(logN)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Range query</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>override</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(ssize_t <em>first, ssize_t </em>last, Value const& __value)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">void</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(logN)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Let the element in the array index from <span class="monospaced">__first</span> to <span class="monospaced">__last</span>
+be <span class="monospaced">__value</span></p></td>
+</tr>
+<tr>
+<td class="tableblock halign-right valign-top" ><p class="tableblock"></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>offset</strong></p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">(ssize_t <em>first, ssize_t </em>last, Value const& __value)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">void</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">O(logN)</p></td>
+<td class="tableblock halign-left valign-top" ><p class="tableblock">Let the element in the array index from <span class="monospaced">__first</span> to <span class="monospaced">__last</span>
+plus <span class="monospaced">__value</span></p></td>
+</tr>
+</tbody>
+</table>
+<hr>
+</div>
+</div>
+</div>
+</div>
+<div id="footnotes"><hr></div>
+<div id="footer">
+<div id="footer-text">
+Last updated 2014-04-19 23:38:26 CST
+</div>
+</div>
+</body>
+</html>
diff --git a/description.asciidoc b/description.asciidoc index 09b6ef9..f768289 100644 --- a/description.asciidoc +++ b/description.asciidoc @@ -1 +1,37 @@ -== hi! += meow + + +== Description +一個不需要, 也不建議先compile成obj files的templates. + +TIP: *README.html* is more beautiful. + +== File Tree +=== *meowpp/* C++ templates + +[width="90%"] +* *utility.h* some useful functions, + `stringPringf()` , `stringReplace` , `cstringEndWith` , + `debugPrintf()` , `messagePrintf()` , `constant PI` , + `noEPS()` , `normalize()` , `denormalize` , + `ratioMapping` , `inRange()` , `squ()` , `average()` +* *Usage.h* `class Usage` +* *colors/* Color splces and transformer +** *RGB.h* `class RGBi` , `class RGBf` +** *YUV.h* `class YUVi` , `class YUVf` , `RGB_to_YUV()` , `YUV_to_RGB` +** *HSL.h* `class HSLf` , `RGB_to_HSL()` , `HSL_to_RGB` , + `YUV_to_HSL()` , `HSL_to_YUV` +** *HSV.h* `class HSVf` , `RGB_to_HSV()` , `HSV_to_RGB` , + `YUV_to_HSV()` , `HSV_to_YUV` , + `HSL_to_HSV()` , `HSV_to_HSL` +* *dsa/* Data Structures and Algorithms +** *DisjointSet.h* `class DisjointSet` +** *Heaps.h* `class MergeableHeap` +** *KD_Tree.h* `class KD_Tree` +** *SplayTree.h* `class SplayTree` +* *oo/* +** *Register_Implement.h* `class RegisterInterface` , + `class ImplementInterface` + +== Structures/Classes/Functions + diff --git a/meowpp/Usage.h b/meowpp/Usage.h index b98a7ac..22f7329 100644 --- a/meowpp/Usage.h +++ b/meowpp/Usage.h @@ -52,7 +52,6 @@ namespace meow{ }; typedef std::map<unsigned char, Option> Options; typedef Options::const_iterator OptionsIterator; - //typedef std::map<unsigned char, Option>::const_iterator OptionsIterator; public: Usage(); Usage(String const& _name); @@ -89,6 +88,68 @@ namespace meow{ Strings usage_end ; Strings proc_arguments; }; + /******************************************************************* + @asciidoc + === meow:: *Usage* (C++ Class) + .Description + `Usage` 是用來分析argc, argv和輸出usage document的class. + argc, argv的部份, 有以下規則 + + * `-c` 其中 `c` 可以代換成正常的一個字元的字符, + 這種選像要嘛就是 *有設置* , 不然就是 *沒設置* + * `-c <value>` 附加一個value, 這種選項可以是選擇性 ,即要設定與否都可以, + 反之則一定要設定. 另外可以給定value的預設值以及哪些value是可接受的 + * `<value>` 其他, 一律視為process arguments + + .Methods + * `Usage(String const& _name)` + + 建構子, 所有說明文字中 *<name>* 都會被代換成 `_name` + * `Usage()` + + 建構子, `_name` 自動取為 " *nobody* " + * `import(Usage const& usage)` + + 將另一個usage的設定匯入, 回傳成功與否 *(bool)* + * `update(Usage const& usage)` + + 將另一個usage分析argc,argv出來的資料拿來用, 回傳成功與否 *(bool)* + * `addOption(unsigned char option, String const& description)` + + 新增一個不接額外選項的參數, 並附上說明文字, 回傳成功與否 *(bool)* + * `addOption(unsigned char option, String const& description, + String const& value_type, String const& value_default, bool must)` + + 新增一個有額外選項的參數, 並附上說明文字, 額外選項的型別跟預設值. + 說明文字中所有的" *<types>* "將會被取代指定的型別, 其中 `must` 代表 + " *是否一定要設定此參數* " , 回傳表成功與否 *(bool)* + * `addOptionValueAccept(unsigned char option, + String const& value, String const& description)` + + 針對某個option, 新增一個可接受的額外選項 (如果某個option從頭到尾都沒有 + 新增可接受的選項, 則視為不限制), 回傳成功與否 *(bool)* + * `hasOptionSetup(unsigned char option)` + + 回傳是否有此選項 *(bool)* + * `getOptionValuesCount(unsigned char option)` + + 回傳此參數被設置了幾次 *(size_t)* , 只對有接額外參數的有效 + * `getOptionValue(unsigned char option, size_t index)` + + 回傳第`index`個額外選項 *(String)* + * `getProcArgsCount()` + + 回傳有多少個Process Arguments *(size_t)* + * `getProcArg(size_t index)` + + 取得第`index`個Process Argument *(String)* + * `getProcArgs()` + + 回傳一個陣列, 包含所有Process Arguments *(Strings)* + * `addUsageBegin(String const& des)` + + 新增一段usage document於每個選項逐條說明之前 + * `addUsageEnd (String const& des)` + + 新增一段usage document於每個選項逐條說明之後 + * `String getUsage()` + + 回傳usage document *(String)* + * `setArguments(int argc, char** argv, String* errmsg)` + + 輸入argv, argc, 回傳是否沒有錯誤發生 *(bool)* , 其中如果有錯誤發生, + 且 `errmsg != NULL` 則會將錯誤訊息寫入之 + +NOTE: `String` 是 `std::string` . + +`Strings` 是 `std::vector< std::string> >`. + +如果沒有寫回傳什麼, 就是回傳 `void` + +''' +@asciidoc- + ******************************************************************/ } #include "Usage.hpp" diff --git a/meowpp/dsa/DisjointSet.h b/meowpp/dsa/DisjointSet.h index 1ea6d97..b33a839 100644 --- a/meowpp/dsa/DisjointSet.h +++ b/meowpp/dsa/DisjointSet.h @@ -24,6 +24,32 @@ namespace meow{ void reset(size_t _n ); size_t merge(size_t a, size_t b); }; + /********************************************************* + @asciidoc + === meow:: *DisjointSet* (C++ class) + .Description + `DisjointSet` is a lighting data structure that maintain N numbers from + *0* to *N-1* with methods below: + + [options="header",width="100%",cols="1>,1<s,5<,1<,1<,10<",grid="rows"] + |======================================================================= + |Const?|Name| Parameters| Return Type| Time Complexity| Description + |const|root|(size_t number)|size_t|very fast| + Return the *group id* of the number given + |const|size|()|size_t|very fast| + Return *N* + ||reset|(size_t N)|void|very fast| + Clean and initalize + ||merge|(size_t number1, + + size_t number2)|size_t|very fast| + *Union* the group contains number1 and the group contains number2. + Return the merged group id + |======================================================================= +NOTE: *very fast* means that you can consider it as constant time. + +''' +@asciidoc- + *********************************************************/ } #include "DisjointSet.hpp" diff --git a/meowpp/dsa/Heaps.h b/meowpp/dsa/Heaps.h index cac3e01..1e47afd 100644 --- a/meowpp/dsa/Heaps.h +++ b/meowpp/dsa/Heaps.h @@ -4,45 +4,6 @@ #include <cstdlib> namespace meow{ - /********************************************************* - @asciidoc - === MergeableHeap<Key, Value> - .Description - MergeableHeap is a kind of maximum-heap with an extra method `merge`, - which will merge another MergeableHeap into itself. - - .Support methods - * N <- number of elements in the heap - * M <- number of elements in the other heap if need - [options="header",width="100%",cols="1>,1<s,5<,1<,1<,10<",grid="rows"] - |======================================================================= - |Const?|Name| Parameters| Return Type| Time Complexity| Description - ||operator= | (MergeableHeap const&)| *this | O(N) - | Copy operator. - ||moveTo | (MergeableHeap*) | void | O(M) - | Transform the this->data to the heap specified in parameters - |const|top | () | Element | O(1) - | Return the maximum element in the heap. - |const|size | () | size_t | O(1) - | Return the number of elements in the heap. - |const|empty| () | bool | O(1) - | Return whether the heap is empty or not. - ||push |(Element) |void | O(log N) - | Add a element into the heap - ||pop |() |void | O(log N) - | Delete the maximum element from the heap - ||merge |(MergeableHeap*) |void | O(log M) - | Merge the specified MergeableHeap(with size=M) into itself - ||clear |() |void | O(N) - | Delete all elements from the heap - |======================================================================= - -WARNING: Consider there are two MergeableHeap `A` and `B`. -`B` will become empty after you call `A.merge(&B)`. -The data in `B` will override by data in `A` and `A` will become empty after -you call `A.moveTo(&B)` - @asciidoc- - *********************************************************/ template<class Element> class MergeableHeap{ // maximum-heap private: @@ -77,6 +38,51 @@ you call `A.moveTo(&B)` void clear( ); void merge(MergeableHeap* _heap2); }; + + /********************************************************* + @asciidoc + === meow:: *MergeableHeap<Key, Value>* (C++ class) + .Description + MergeableHeap is a kind of maximum-heap with a special method `merge`, + which will merge another MergeableHeap into itself in O(logN) time. + + .Template Request + * `Key` should has `operator<` + + .Support methods + * N <- number of elements in the heap + * M <- number of elements in the other heap if need + [options="header",width="100%",cols="1>,1<s,3<,1<,1<,10<",grid="rows"] + |======================================================================= + |Const?|Name| Parameters| Return Type| Time Complexity| Description + ||operator= | (MergeableHeap const&)| *this | O(N) + | Copy operator. + ||moveTo | (MergeableHeap*) | void | O(M) + | Transform the this->data to the heap specified in parameters + |const|top | () | Element | O(1) + | Return the maximum element in the heap. + |const|size | () | size_t | O(1) + | Return the number of elements in the heap. + |const|empty| () | bool | O(1) + | Return whether the heap is empty or not. + ||push |(Element) |void | O(log N) + | Add a element into the heap + ||pop |() |void | O(log N) + | Delete the maximum element from the heap + ||merge |(MergeableHeap*) |void | O(log M) + | Merge the specified MergeableHeap(with size=M) into itself + ||clear |() |void | O(N) + | Delete all elements from the heap + |======================================================================= + +WARNING: Consider there are two MergeableHeap `A` and `B`. + +`B` will become empty after you call `A.merge(&B)`. + +The data in `B` will override by data in `A` and `A` will become empty after +you call `A.moveTo(&B)` + +''' +@asciidoc- + *********************************************************/ } #include "MergeableHeap.hpp" diff --git a/meowpp/dsa/KD_Tree.h b/meowpp/dsa/KD_Tree.h index 0abc358..2e55d12 100644 --- a/meowpp/dsa/KD_Tree.h +++ b/meowpp/dsa/KD_Tree.h @@ -68,6 +68,48 @@ namespace meow{ void clear(); void reset(size_t _dimension); }; + /********************************************************* + @asciidoc + === meow:: *KD_Tree<Keys, Key, Value>* (C++ class) + .Description + `KD_Tree` is *K-dimension tree*, which is a dictionary(key->value). + Where the type if key is a *K-dimension vector* . + + .Template Request + * `Keys` should has `operator[]` to allow the KD_Tree access the k-dimensions + * `Key` should has `operator*`, `operator+` + + .Support Methods + * N <- numbers of element in the kd-tree + * K <- dimensions + * `Keys` is the tyepname of the vector + * `Key` is the typename of the element in the vector + * `Value` is the typename of value + [options="header",width="100%",cols="1>,1<s,5<,1<,2<,10<",grid="rows"] + |======================================================================= + |Const?|Name| Parameters| Return Type| Time Complexity| Description + |const|root|(size_t number)|size_t|very fast| + ||insert|(Key const& k, Value v)|void|O(1)|Insert a pair (k->v) + || build|()|void|O(KN logN) | Build the data structure(the `insert()` + method will not build the data structure immediately) + |const|query|(Keys const& point, int k)|Value|O(kN ^1-1/k^ ) | + Using Euclidean-Distance to find the k-nearest neighbor from `point` . + And return the corrosponding value + |const|query|(Keys const& point, int k)|std::vector<Value>|O(kN ^1-1/k^ ) | + Using Euclidean-Distance to find all the x-nearest neighbor from `point` , + where x <= k. And return an array of all the corrosponding value. + ||clear|()|O(1)|Clear all data + ||reset|(size_t dimension)|O(1)|Clear all data and then + set the this->dimension be `dimension` + |======================================================================= +NOTE: O(kN ^1-1/k^ ) is reference from wiki. + +`query()` and `rangeQuery()` will run `build()` first if you called `insert()` +before call them. And `build()` is very slow, so you should not use this class +as a dynamic tree + +''' +@asciidoc- + *********************************************************/ } #include "KD_Tree.hpp" diff --git a/meowpp/dsa/MergeableHeap.hpp b/meowpp/dsa/MergeableHeap.hpp index de3aea9..6e49a1c 100644 --- a/meowpp/dsa/MergeableHeap.hpp +++ b/meowpp/dsa/MergeableHeap.hpp @@ -1,6 +1,3 @@ -// @class name : MergeableHeap -// @implement : Leftist Tree - #include <cstdlib> namespace meow{ diff --git a/meowpp/dsa/SegmentTree.h b/meowpp/dsa/SegmentTree.h new file mode 100644 index 0000000..1aa396d --- /dev/null +++ b/meowpp/dsa/SegmentTree.h @@ -0,0 +1,92 @@ +#ifndef SegmentTree_H__ +#define SegmentTree_H__ + +namespace meow{ + template<class Value> + class SegmentTree{ + private: + struct Node{ + Value _value; + Value _offset; + bool _sameFlag; + // + Node(); + }; + // + size_t _size; + std::vector<Node> _nodes; + size_t const _root; + // + size_t leftChild(size_t __parent) const; + size_t rightChild(size_t __parent) const; + // + void downUpdate(size_t __L, size_t __R, size_t __index); + void override(size_t __l, size_t __r, + size_t __L, size_t __R, + size_t __index, Value const& __value); + void offset(size_t __l, size_t __r, + size_t __L, size_t __R, + size_t __index, Value const& __delta); + Value query(size_t __l, size_t __r, + size_t __L, size_t __R, + size_t __index); + bool rangeCorrect(ssize_t* __first, ssize_t* __last) const; + public: + SegmentTree(); + SegmentTree(size_t __size); + SegmentTree(SegmentTree const& __tree2); + // + void reset(size_t __size); + // + Value query (ssize_t __first, ssize_t __last) const; + void override(ssize_t __first, ssize_t __last, Value const& __value); + void offset (ssize_t __first, ssize_t __last, Value const& __delta); + }; + /********************************************************* + @asciidoc + === meow:: *SegmentTree<Value>* (C++ class) + .Description + `SegmentTree` is a data structure that can maintain an array, and + support *range update* , *range query* + + .Template Request + * `Value` should has + ** `operator+(Value)` offset + ** `operator|(Value)` merge two nodes + ** `operator*(size_t)` ?? + + For example, if you want to maintain *range minimum* + + * `Value::operator+(Value v2)` will be `this->realValue + v2.realValue` + * `Value::operator|(Value v2)` will be `std::min(this->realValue, v2.realValue)` + * `Value::operator*(size_t n)` will be `this->realValue` + + If you want to maintain *range sum* + + * `Value::operator+(Value v2)` will be `this->realValue + v2.realValue` + * `Value::operator|(Value v2)` will be `this->realValue + v2.realValue)` + * `Value::operator*(size_t n)` will be `this->realValue * n` + + .Support methods + * N <- array size + [options="header",width="100%",cols="1>,1<s,3<,1<,1<,10<",grid="rows"] + |======================================================================= + |Const?|Name| Parameters| Return Type| Time Complexity| Description + ||reset|(size_t N)|void|O(1)| + Clear and reset the array size to N (from `0` to `N - 1`) + |const|query|(ssize_t __first, ssize_t __last)|Value|O(logN)| + Range query + ||override|(ssize_t __first, ssize_t __last, Value const& __value)|void| + O(logN)| Let the element in the array index from `__first` to `__last` + be `__value` + ||offset|(ssize_t __first, ssize_t __last, Value const& __value)|void| + O(logN)| Let the element in the array index from `__first` to `__last` + plus `__value` + |======================================================================= + +''' +@asciidoc- + *********************************************************/ +} + +#endif diff --git a/meowpp/dsa/SegmentTree.hpp b/meowpp/dsa/SegmentTree.hpp new file mode 100644 index 0000000..24efcdd --- /dev/null +++ b/meowpp/dsa/SegmentTree.hpp @@ -0,0 +1,172 @@ +#ifndef SegmentTree_H__ +#define SegmentTree_H__ + +namespace meow{ + template<class Value> + inline SegmentTree<Value>::Node::Node(){ } + + template<class Value> + inline size_t + SegmentTree<Value>::leftChild(size_t __parent) const { + return __parent * 2 + 1; + } + template<class Value> + inline size_t + SegmentTree<Value>::rightChild(size_t __parent) const { + return __parent * 2 + 2; + } + + template<class Value> + inline void + SegmentTree<Value>::downUpdate(size_t __L, size_t __R, size_t __index){ + size_t mid = (__L + __R) / 2; + Value& val = _nodes[__index]._value; + Value& off = _nodes[__index]._offset; + if(_nodes[__index]._sameFlag){ + if(__L < __R){ + override(__L , mid, __L , mid, leftChild(__index), val); + override(mid + 1, __R, mid + 1, __R, rightChild(__index), val); + } + _nodes[__index]._sameFlag = false; + _nodes[__index]._offset = 0; + }else if(!(_nodes[__index]._offset == Value(0))){ + if(__L < __R){ + offset(__L , mid, __L , mid, leftChild(__index), off); + offset(mid + 1, __R, mid + 1, __R, rightChild(__index), off); + } + _nodes[__index]._offset = 0; + } + } + template<class Value> + inline void + SegmentTree<Value>::override(size_t __l, size_t __r, + size_t __L, size_t __R, + size_t __index, Value const& __value){ + if(__l == __L && __r == __R){ + _nodes[__index]._value = __value * (__R - __L + 1); + _nodes[__index]._offset = 0; + _nodes[__index]._sameFlag = true; + return ; + } + downUpdate(__L, __R, __index); + size_t mid = (__L + __R) / 2; + if(__r <= mid){ + override(__l, __r, __L , mid, leftChild(__index), __value); + }else if(mid + 1 <= __l){ + override(__l, __r, mid + 1, __R, rightChild(__index), __value); + }else{ + override(__l , mid, __L , mid, leftChild(__index), __value); + override(mid + 1, __r, mid + 1, __R, rightChild(__index), __value); + } + _nodes[__index]._value = ( _nodes[ leftChild(__index)]._value + | _nodes[rightChild(__index)]._value); + } + template<class Value> + inline void + SegmentTree<Value>::offset(size_t __l, size_t __r, + size_t __L, size_t __R, + size_t __index, Value const& __delta){ + if(__l == __L && __r == __R){ + _nodes[__index]._value = _nodes[__index]._value + __delta*(__R-__L+1); + if(!_nodes[__index]._sameFlag){ + _nodes[__index]._offset = _nodes[__index]._offset + __delta; + } + return ; + } + downUpdate(__L, __R, __index); + size_t mid = (__L + __R) / 2; + if(__r <= mid){ + offset(__l, __r, __L , mid, leftChild(__index), __delta); + }else if(mid + 1 <= __l){ + offset(__l, __r, mid + 1, __R, rightChild(__index), __delta); + }else{ + offset(__l , mid, __L , mid, leftChild(__index), __delta); + offset(mid + 1, __r, mid + 1, __R, rightChild(__index), __delta); + } + _nodes[__index]._value = ( _nodes[ leftChild(__index)]._value + | _nodes[rightChild(__index)]._value); + } + template<class Value> + inline Value + SegmentTree<Value>::query(size_t __l, size_t __r, + size_t __L, size_t __R, + size_t __index){ + if((__l == __L && __r == __R) || _nodes[__index]._sameFlag){ + return _nodes[__index]._value; + } + size_t mid = (__L + __R) / 2; + Value& off = _nodes[__index]._offset; + if(__r <= mid){ + return query(__l, __r, __L , mid, leftChild(__index)) + off; + }else if(mid + 1 <= __l){ + return query(__l, __r, mid + 1, __R, rightChild(__index)) + off; + }else{ + return ( query(__l , mid, __L , mid, leftChild(__index)) + | query(mid + 1, __r, mid + 1, __R, rightChild(__index))) + off; + } + } + template<class Value> + inline bool + SegmentTree<Value>::rangeCorrect(ssize_t* __first, ssize_t* __last) const{ + if(*__last < *__first){ + return false; + } + if(*__last < 0 || _size - 1 < *__first){ + return false; + } + *__first = inRange((ssize_t)0, (ssize_t)_size - 1, *__first); + *__last = inRange((ssize_t)0, (ssize_t)_size - 1, *__last ); + return true; + } + + template<class Value> + inline + SegmentTree<Value>::SegmentTree(): _size(0), _root(0) { + } + template<class Value> + inline + SegmentTree<Value>::SegmentTree(size_t __size): _size(0), _root(0){ + reset(__size); + } + template<class Value> + inline + SegmentTree<Value>::SegmentTree(SegmentTree const& __tree2): + _size(__tree2._size), _nodes(__tree2._nodes), _root(0){ } + // + template<class Value> + inline void + SegmentTree<Value>::reset(size_t __size){ + _size = __size; + _nodes.resize(__size * 4); + _nodes[_root]._sameFlag = true; + _nodes[_root]._value = Value(0); + } + template<class Value> + inline Value + SegmentTree<Value>::query(ssize_t __first, ssize_t __last) const{ + if(rangeCorrect(&__first, &__last) == false){ + return Value(); + } + return ((SegmentTree*)this)->query(__first, __last, 0, _size - 1, _root); + } + template<class Value> + inline void + SegmentTree<Value>::override(ssize_t __first, ssize_t __last, + Value const& __value){ + if(rangeCorrect(&__first, &__last) == false){ + return ; + } + override(__first, __last, 0, _size - 1, _root, __value); + } + template<class Value> + inline void + SegmentTree<Value>::offset(ssize_t __first, ssize_t __last, + Value const& __delta){ + if(rangeCorrect(&__first, &__last) == false){ + return ; + } + offset(__first, __last, 0, _size - 1, _root, __delta); + } +} + +#endif diff --git a/meowpp/dsa/SplayTree.h b/meowpp/dsa/SplayTree.h index 78b54f6..3d2d2e3 100644 --- a/meowpp/dsa/SplayTree.h +++ b/meowpp/dsa/SplayTree.h @@ -96,6 +96,81 @@ namespace meow{ // void print() const; }; + /********************************************************* + @asciidoc + === meow:: *SplayTree<Key, Value>* (C++ class) + .Description + Like `std::map`, `SplayTree` is an dictionary(key->value). But it has + some extra method, such as `split()`, `merge()`, `keyOffset()`. + + .Data Type + * `Key` is the tyepname of the key + * `Value` is the typename of value + * `SplayTree<Key, Value>:: *Element* ` is a typename which contain + (key->value). It has some methods below: + ** `->first ` a constant reference to `Key` + ** `->second` a reference to `Value` + ** `operator==, operator!=` compare function, check if the two `Element` + is pointer to the same (key->value) + + .Template Request + * `Key` should has `operator<`, `operator+` + + .Support Methods + * N <- numbers of element in the SplayTree + * M <- numbers of element in another SplayTree + [options="header",width="100%",cols="1>,1<s,5<,1<,3^,10<",grid="rows"] + |======================================================================= + |Const?|Name| Parameters| Return Type| Time Complexity| Description + ||operator=|(SplayTree const&)| *this | O(N) | copy operator + ||moveTo|(SplayTree* t)|void|O(M)| Transform the data in this to `t` + |const|lowerBound|(Key k)|Element|O(logN)| Find the smallest (key->value) + which `k <= key` and return + |const|upperBound|(Key k)|Element|O(logN)| Find the smallest (key->value) + which `k < key` and return + |const|rLowerBound|(Key k)|Element|O(logN)| Find the largest (key->value) + which `key <= k` and return + |const|rUpperBound|(Key k)|Element|O(logN)| Find the largest (key->value) + which `key < k` and return + |const| find|(Key k)|Element|O(logN)| Find the element (key->value) which + `key == k` and return + |const|order|(size_t k)|Element|O(logN)| Find the `k`-th small element. + note that `k` start from zero like a normal C/C++ array. + |const|first|()|Element|O(logN)| Return the smallest element + |const|last|()|Element|O(logN)| Return the largest element + |const|end|()|Element|O(1)|Return an empty element(it can be use to + check if `find()` is successful) + |const|size|()|size_t|O(1)| Return number of elements in the tree + |const|empty|()|bool|O(1)|Return whether the tree is empty + ||clear|()|void|O(N)|Clear + ||keyOffset|(Key offset)|void|O(1)| Let all the keys in the tree + plus offset + ||insert|(Key k, Value v)|bool | O(logN)| Insert an element. + If the tree already has an element with same key, return `false`. + ||erase|(Key k)|bool | O(logN)|Erase an element from the tree with + given key. Return `false` if the element not found. + ||operator[]|(Key k)|Value|O(logN)|Like `find()` , but it will insert an element + automatic if the corrosponding element not found + ||splitOut|(Key const& upper_bound, + + SplayTree* out)|void | O(log N) | Split out all the elements with key + larger than `upper_bound` and store then into `out` + ||mergeAfter|(SplayTree* t)|bool|O(logN + logM)|If not all of the elements in this + are smaller than elements in `t`, return `false` , else merge `t` into + itself and return `true`. + ||merge|(SplayTree* t)|bool|O(logN + logM)|If all of the elements in this + are smaller than elements in `t` or all of the elements in this larger than + elements in `t` , merge `t` into itself and return `true`. + Else return `false` + |======================================================================= +WARNING: Consider there are two SplayTree `A` and `B`. + +`B` will become empty after you call `A.mergeAfter(&B)` +or `A.merge(&B)` successful. + +The data in `B` will override by data in `A` and `A` will become empty after +you call `A.moveTo(&B)` + +''' +@asciidoc- + *********************************************************/ } #include "SplayTree.hpp" diff --git a/meowpp/oo/Register_Implement.h b/meowpp/oo/Register_Implement.h index e46f86c..dd496fa 100644 --- a/meowpp/oo/Register_Implement.h +++ b/meowpp/oo/Register_Implement.h @@ -26,6 +26,26 @@ namespace meow{ virtual ImplementInterface<T>* getImplement(T const& identify); virtual ~RegisterInterface(){ } }; + /******************************************************************* + @asciidoc + === meow:: *ImplementInterface/RegisterInterface* (C++ Class) + .Description + Assume there is a problem which can be solved by different algorithms. + Then you can write multiple classes to approach this problem. + + Now if you want to decide which algorithm to use in runtime, you can just + approach this case by a simple way: + + * Let all the problem-solving classes inherit from + `class ImplementInterface<T>` , and call the constructure with giving + `identify` (type `T` ) . + * Create an object, type `RegisterInterface<T>` , and register all your + implement class to it by call `regImplement(pointer to the class)`. + * Select which implement class you want by call `getImplement(identify)` , + which will return the pointer to the corresponding class. + + ''' + @asciidoc- + ******************************************************************/ } #include "Register_Implement.hpp" diff --git a/meowpp/oo/Register_Implement.hpp b/meowpp/oo/Register_Implement.hpp index 523f266..34d9129 100644 --- a/meowpp/oo/Register_Implement.hpp +++ b/meowpp/oo/Register_Implement.hpp @@ -13,9 +13,8 @@ namespace meow{ return true; } template<class T> - inline ImplementInterface<T>* RegisterInterface<T>::getImplement( - T const& identify - ){ + inline ImplementInterface<T>* + RegisterInterface<T>::getImplement(T const& identify){ if(implements.find(identify) == implements.end()){ return NULL; } diff --git a/meowpp/utility.h b/meowpp/utility.h index 156971a..4f3b36a 100644 --- a/meowpp/utility.h +++ b/meowpp/utility.h @@ -6,7 +6,6 @@ #include <cctype> namespace meow{ - inline std::string stringPrintf(char const * fmt, ...); inline std::string stringReplace(std::string str, std::string const& from, @@ -40,6 +39,60 @@ namespace meow{ inline double average(T const& beg, T const& end, double sigs); template<class T> inline double average(T const& beg, T const& end, T const& p, double sigs); + + /******************************************************************* + @asciidoc + === meow:: *Functios* in utility.h + [options="header",width="100%",cols="1>s,5<,1<,10<",grid="rows"] + |============================================================== + |Name | Parameters | Return Type | Description + |stringPrintf |(char const * fmt, ...)|std::string | + Format print to C++ string and return it + |stringReplace |(std::string str, + + std::string const& from, + + std::string const& to) | std::string | + Return a string like `str`, but all `from` be replaced by `to` + |cstringEndWith |(char const* str, int n, ...) | bool | + Return whether `str` is end with one of the c-string you specify in + the parameters or not + |debugPrintf |(char const* fmt, ...) | void| + Print debug message (file name, line number, ...etc) when `DEBUG` is + defined + |messagePrintf |(int level_change, char const* fmt, ...) | void| + 階層式的訊息輸出 + |noEPS |(double value, double eps = 1e-9) | double | + 如果abs(輸入的數值) < eps, 則回傳0, 否則回傳輸入的數值 + |normalize |(double lower, double upper, + + double value) | double | + (value - lower) / (upper - lower) + |denormalize |(double lower, double upper, + + double ratio) | double | + lower + (upper - lower) * ratio + |ratioMapping |(double l1, double u1, + + double m1, double l2, + + double u2) + | double | + denormalize(l2, u2, normalize(l1, u1, m1)) + |inRange<T> |(T const& mn, T const& mx, + + T const& v) | T | + std::max(mn, std::min(mx, v)) + |squ<T> |(T const& x) | T| + x * x + |average<T>|(T const& beg, T const& end, + + double sigs)| T| + 只將 `sigs` 個標準差以內的數據拿來取平均 + |average<T>|(T const& beg, T const& end, + + T const& p, double sigs)| T| + 同上, 不過這次用 `p` 來加權平均 + |============================================================== + + [NOTE] + `stringReplace()` 不是用什麼好方法寫的因此執行效率很低請別虐待它. + + 額外附贈一個 `const double PI = 3.141592653589......` + +''' +@asciidoc- + ******************************************************************/ } #include "utility.hpp" diff --git a/readme_generate.py b/readme_generate.py index 781e2d3..7eb6782 100755 --- a/readme_generate.py +++ b/readme_generate.py @@ -76,11 +76,15 @@ readme_f = open(readme, 'w'); for (root, sub_folders, files) in os.walk('./'): for reader in readers: + deleted = [] for filename in files: path = os.path.join(root, filename); if path == './' + readme: continue; if reader.checkOk(filename): + print 'Get asciidoc from ' + path; readme_f.write(reader.read(path)); - files.remove(filename); + deleted.append(filename); + for filename in deleted: + files.remove(filename); readme_f.close(); |