![]() |
Templates -- Meow
1.2.9
A C++ template contains kinds of interesting classes and functions
|
基本上跟SplayTree一樣, 不過這邊結合線段樹, 多了區間操作 (線段樹相關operator定義請見 SegmentTree
)
More...
#include "SplayTree.h"
Classes | |
class | Element |
類似 stl 的 iterator ,不過這邊叫做Element More... | |
Public Member Functions | |
SplayTree_Range () | |
constructor More... | |
SplayTree_Range (SplayTree_Range const &tree2) | |
constructor, 複製資料 More... | |
~SplayTree_Range () | |
destructor More... | |
SplayTree_Range & | copyFrom (SplayTree_Range const &tree2) |
複製資料 More... | |
void | moveTo (SplayTree_Range *tree2) |
將資料都丟到 tree2 身上, 並且清空自己 More... | |
Element | lowerBound (Key const &key) const |
找出第一個(最小的) Element且 k <= 它的 Key, 並且回傳之. More... | |
Element | upperBound (Key const &key) const |
找出第一個(最小的) Element且 k < 它的 Key, 並且回傳之. More... | |
Element | rLowerBound (Key const &key) const |
找出第一個(最小的) Element且 k >= 它的 Key, 並且回傳之. More... | |
Element | rUpperBound (Key const &key) const |
找出第一個(最小的) Element且 k > 它的 Key, 並且回傳之. More... | |
Element | find (Key const &key) const |
找出 Key= k 的Elemenet 並回傳. 找不到的話回傳 this->end() More... | |
Element | order (size_t order) const |
將Elements依照Key由小到大排序, 回傳第 ord 個Element (由0算起). More... | |
Element | first () const |
回傳Key最小的Element, 如果SplayTree為空, 則回傳 this->end() More... | |
Element | last () const |
回傳Key最大的Element, 如果SplayTree為空, 則回傳 this->end() More... | |
Element | end () const |
回傳一個指向NULL的Element, More... | |
size_t | size () const |
回傳資料個數 More... | |
bool | empty () const |
回傳是否為空 More... | |
Value | query () const |
查找 More... | |
Value | query (Key const &first, Key const &last) const |
查找 More... | |
void | clear () |
清空 More... | |
bool | insert (Key const &key, Value const &value) |
插入一組 (Key —> Value ) More... | |
bool | erase (Key const &key) |
刪除一組資料 More... | |
void | keyOffset (Key const &delta) |
將所有Element的Key同加上 delta More... | |
void | valueOffset (Value const &delta) |
將所有Element的Value同加上 delta More... | |
void | valueOverride (Value const &value) |
將所有Element的Value全部設定成value More... | |
void | splitOut (Key const &upper_bound, SplayTree_Range *right) |
將tree2 清空, 再將所有Key > upper_bound 的Element都丟過去 More... | |
bool | mergeAfter (SplayTree_Range *tree2) |
合併 More... | |
bool | merge (SplayTree_Range *tree2) |
合併 More... | |
Value & | operator[] (Key const &key) |
就像stl::map::operator [] More... | |
SplayTree_Range & | operator= (SplayTree_Range const &tree2) |
same as copyFrom(tree2) More... | |
基本上跟SplayTree一樣, 不過這邊結合線段樹, 多了區間操作 (線段樹相關operator定義請見 SegmentTree
)
const? | Typename | Operator | Parameters | Return Type | Description |
---|---|---|---|---|---|
const | Key | operator+ | (Key k ) | Key | 相加 |
const | Key | operator< | (Key k ) | bool | 大小比較 |
Key | operator= | (Key k ) | Key | copy oper | |
Key | Key | (int n ) | 構子,n 永遠是0 | ||
Value | Value | ( ) | 建構子 |
A
和 B
, 則: -執行 B.moveTo(&A)
後 B
會變成空的, A
原本擁有的資料也會覆蓋掉 -行 A.merge(&B)
或 A.mergeAfter(&B)
後 如果檢查發現確實可以merge, 則之後 B
會變成空的Definition at line 569 of file SplayTree.h.
|
inline |
constructor
Definition at line 812 of file SplayTree.h.
|
inline |
constructor, 複製資料
Definition at line 816 of file SplayTree.h.
|
inline |
destructor
Definition at line 821 of file SplayTree.h.
|
inline |
清空
Definition at line 988 of file SplayTree.h.
|
inline |
複製資料
Definition at line 828 of file SplayTree.h.
|
inline |
回傳是否為空
Definition at line 952 of file SplayTree.h.
|
inline |
回傳一個指向NULL的Element,
以供 find
,order
,first
,last
等判斷是否有找到相對應的Element
Definition at line 938 of file SplayTree.h.
|
inline |
刪除一組資料
檢查是否已有Element的Key 為 key
, 若有則刪除之, 並回傳 true
, 否則則回傳 false
Definition at line 1023 of file SplayTree.h.
|
inline |
找出 Key= k
的Elemenet 並回傳. 找不到的話回傳 this->end()
Definition at line 898 of file SplayTree.h.
|
inline |
回傳Key最小的Element, 如果SplayTree為空, 則回傳 this->end()
Definition at line 920 of file SplayTree.h.
|
inline |
插入一組(Key —>
Value
)
檢查是否已有Element的Key 為 key
, 若有則回傳 false
, 否則將 一個 (Key -> Value) = (key
-> value
)的Element加入, 並回傳 true
Definition at line 999 of file SplayTree.h.
|
inline |
將所有Element的Key同加上 delta
Definition at line 1056 of file SplayTree.h.
|
inline |
回傳Key最大的Element, 如果SplayTree為空, 則回傳 this->end()
Definition at line 928 of file SplayTree.h.
|
inline |
找出第一個(最小的) Element且 k
<= 它的 Key, 並且回傳之.
找不到的話回傳 this->end()
Definition at line 848 of file SplayTree.h.
|
inline |
合併
檢查是否自己中的 Key 都小於 tree2
中的Key, 或是完全相反, 是的話把 tree2`中的
Element 都搬到自己這, 同時清空 tree2
, 否則回傳 false
Definition at line 1117 of file SplayTree.h.
|
inline |
合併
檢查是否自己中的 Key 都小於 tree2
中的Key, 是的話把 tree2`
中的 Element 都搬到自己這, 同時清空 tree2
, 否則回傳 false
Definition at line 1100 of file SplayTree.h.
|
inline |
將資料都丟到 tree2
身上, 並且清空自己
Definition at line 837 of file SplayTree.h.
|
inline |
same as copyFrom(tree2)
Definition at line 1144 of file SplayTree.h.
|
inline |
就像stl::map::operator
[]
會先檢查是否已有Element的Key 為 key
, 若有則回傳相對應的Value的Reference 否則先執行 insert(key,Value())
再回傳相對應的Reference
Definition at line 1138 of file SplayTree.h.
|
inline |
將Elements依照Key由小到大排序, 回傳第 ord
個Element (由0算起).
其中如果 ord>N-1
, 則會回傳 this->last()
Definition at line 911 of file SplayTree.h.
|
inline |
|
inline |
|
inline |
找出第一個(最小的) Element且 k
>= 它的 Key, 並且回傳之.
找不到的話回傳 this->end()
Definition at line 874 of file SplayTree.h.
|
inline |
找出第一個(最小的) Element且 k
> 它的 Key, 並且回傳之.
找不到的話回傳 this->end()
Definition at line 887 of file SplayTree.h.
|
inline |
回傳資料個數
Definition at line 945 of file SplayTree.h.
|
inline |
將tree2
清空, 再將所有Key > upper_bound
的Element都丟過去
Definition at line 1083 of file SplayTree.h.
|
inline |
找出第一個(最小的) Element且 k
< 它的 Key, 並且回傳之.
找不到的話回傳 this->end()
Definition at line 861 of file SplayTree.h.
|
inline |
將所有Element的Value同加上 delta
Definition at line 1065 of file SplayTree.h.
|
inline |
將所有Element的Value全部設定成value
Definition at line 1074 of file SplayTree.h.