Templates -- Meow  1.2.9
A C++ template contains kinds of interesting classes and functions
meow::SplayTree_Range< Key, Value > Class Template Reference

基本上跟SplayTree一樣, 不過這邊結合線段樹, 多了區間操作 (線段樹相關operator定義請見 SegmentTree ) More...

#include "SplayTree.h"

Classes

class  Element
 類似 stliterator ,不過這邊叫做Element More...
 

Public Member Functions

 SplayTree_Range ()
 constructor More...
 
 SplayTree_Range (SplayTree_Range const &tree2)
 constructor, 複製資料 More...
 
 ~SplayTree_Range ()
 destructor More...
 
SplayTree_RangecopyFrom (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_Rangeoperator= (SplayTree_Range const &tree2)
 same as copyFrom(tree2) More...
 

Detailed Description

template<class Key, class Value>
class meow::SplayTree_Range< Key, Value >

基本上跟SplayTree一樣, 不過這邊結合線段樹, 多了區間操作 (線段樹相關operator定義請見 SegmentTree )

Template Class Operators Request

const?TypenameOperator 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 ( ) 建構子
Note
: -假設現在有兩個SplayTree AB, 則: -執行 B.moveTo(&A)B 會變成空的, A 原本擁有的資料也會覆蓋掉 -行 A.merge(&B)A.mergeAfter(&B) 後 如果檢查發現確實可以merge, 則之後 B 會變成空的
Author
cat_leopard

Definition at line 569 of file SplayTree.h.

Constructor & Destructor Documentation

template<class Key , class Value >
meow::SplayTree_Range< Key, Value >::SplayTree_Range ( )
inline

constructor

Definition at line 812 of file SplayTree.h.

template<class Key , class Value >
meow::SplayTree_Range< Key, Value >::SplayTree_Range ( SplayTree_Range< Key, Value > const &  tree2)
inline

constructor, 複製資料

Definition at line 816 of file SplayTree.h.

template<class Key , class Value >
meow::SplayTree_Range< Key, Value >::~SplayTree_Range ( )
inline

destructor

Definition at line 821 of file SplayTree.h.

Member Function Documentation

template<class Key , class Value >
void meow::SplayTree_Range< Key, Value >::clear ( )
inline

清空

Definition at line 988 of file SplayTree.h.

template<class Key , class Value >
SplayTree_Range& meow::SplayTree_Range< Key, Value >::copyFrom ( SplayTree_Range< Key, Value > const &  tree2)
inline

複製資料

Definition at line 828 of file SplayTree.h.

template<class Key , class Value >
bool meow::SplayTree_Range< Key, Value >::empty ( ) const
inline

回傳是否為空

Definition at line 952 of file SplayTree.h.

template<class Key , class Value >
Element meow::SplayTree_Range< Key, Value >::end ( ) const
inline

回傳一個指向NULL的Element,

以供 find ,order ,first ,last 等判斷是否有找到相對應的Element

Definition at line 938 of file SplayTree.h.

template<class Key , class Value >
bool meow::SplayTree_Range< Key, Value >::erase ( Key const &  key)
inline

刪除一組資料

檢查是否已有Element的Key 為 key, 若有則刪除之, 並回傳 true, 否則則回傳 false

Definition at line 1023 of file SplayTree.h.

template<class Key , class Value >
Element meow::SplayTree_Range< Key, Value >::find ( Key const &  key) const
inline

找出 Key= k 的Elemenet 並回傳. 找不到的話回傳 this->end()

Definition at line 898 of file SplayTree.h.

template<class Key , class Value >
Element meow::SplayTree_Range< Key, Value >::first ( ) const
inline

回傳Key最小的Element, 如果SplayTree為空, 則回傳 this->end()

Definition at line 920 of file SplayTree.h.

template<class Key , class Value >
bool meow::SplayTree_Range< Key, Value >::insert ( Key const &  key,
Value const &  value 
)
inline

插入一組(Key —> Value)

檢查是否已有Element的Key 為 key, 若有則回傳 false , 否則將 一個 (Key -> Value) = (key -> value)的Element加入, 並回傳 true

Definition at line 999 of file SplayTree.h.

template<class Key , class Value >
void meow::SplayTree_Range< Key, Value >::keyOffset ( Key const &  delta)
inline

將所有Element的Key同加上 delta

Definition at line 1056 of file SplayTree.h.

template<class Key , class Value >
Element meow::SplayTree_Range< Key, Value >::last ( ) const
inline

回傳Key最大的Element, 如果SplayTree為空, 則回傳 this->end()

Definition at line 928 of file SplayTree.h.

template<class Key , class Value >
Element meow::SplayTree_Range< Key, Value >::lowerBound ( Key const &  key) const
inline

找出第一個(最小的) Element且 k <= 它的 Key, 並且回傳之.

找不到的話回傳 this->end()

Definition at line 848 of file SplayTree.h.

template<class Key , class Value >
bool meow::SplayTree_Range< Key, Value >::merge ( SplayTree_Range< Key, Value > *  tree2)
inline

合併

檢查是否自己中的 Key 都小於 tree2 中的Key, 或是完全相反, 是的話把 tree2`中的 Element 都搬到自己這, 同時清空 tree2 , 否則回傳 false

Definition at line 1117 of file SplayTree.h.

template<class Key , class Value >
bool meow::SplayTree_Range< Key, Value >::mergeAfter ( SplayTree_Range< Key, Value > *  tree2)
inline

合併

檢查是否自己中的 Key 都小於 tree2 中的Key, 是的話把 tree2` 中的 Element 都搬到自己這, 同時清空 tree2 , 否則回傳 false

Definition at line 1100 of file SplayTree.h.

template<class Key , class Value >
void meow::SplayTree_Range< Key, Value >::moveTo ( SplayTree_Range< Key, Value > *  tree2)
inline

將資料都丟到 tree2 身上, 並且清空自己

Definition at line 837 of file SplayTree.h.

template<class Key , class Value >
SplayTree_Range& meow::SplayTree_Range< Key, Value >::operator= ( SplayTree_Range< Key, Value > const &  tree2)
inline

same as copyFrom(tree2)

Definition at line 1144 of file SplayTree.h.

template<class Key , class Value >
Value& meow::SplayTree_Range< Key, Value >::operator[] ( Key const &  key)
inline

就像stl::map::operator[]

會先檢查是否已有Element的Key 為 key, 若有則回傳相對應的Value的Reference 否則先執行 insert(key,Value()) 再回傳相對應的Reference

Definition at line 1138 of file SplayTree.h.

template<class Key , class Value >
Element meow::SplayTree_Range< Key, Value >::order ( size_t  order) const
inline

將Elements依照Key由小到大排序, 回傳第 ord 個Element (由0算起).

其中如果 ord>N-1, 則會回傳 this->last()

Definition at line 911 of file SplayTree.h.

template<class Key , class Value >
Value meow::SplayTree_Range< Key, Value >::query ( ) const
inline

查找

詢問目前整個range的值

Definition at line 961 of file SplayTree.h.

template<class Key , class Value >
Value meow::SplayTree_Range< Key, Value >::query ( Key const &  first,
Key const &  last 
) const
inline

查找

詢問給定range的值

Definition at line 971 of file SplayTree.h.

template<class Key , class Value >
Element meow::SplayTree_Range< Key, Value >::rLowerBound ( Key const &  key) const
inline

找出第一個(最小的) Element且 k >= 它的 Key, 並且回傳之.

找不到的話回傳 this->end()

Definition at line 874 of file SplayTree.h.

template<class Key , class Value >
Element meow::SplayTree_Range< Key, Value >::rUpperBound ( Key const &  key) const
inline

找出第一個(最小的) Element且 k > 它的 Key, 並且回傳之.

找不到的話回傳 this->end()

Definition at line 887 of file SplayTree.h.

template<class Key , class Value >
size_t meow::SplayTree_Range< Key, Value >::size ( ) const
inline

回傳資料個數

Definition at line 945 of file SplayTree.h.

template<class Key , class Value >
void meow::SplayTree_Range< Key, Value >::splitOut ( Key const &  upper_bound,
SplayTree_Range< Key, Value > *  right 
)
inline

tree2 清空, 再將所有Key > upper_bound 的Element都丟過去

Definition at line 1083 of file SplayTree.h.

template<class Key , class Value >
Element meow::SplayTree_Range< Key, Value >::upperBound ( Key const &  key) const
inline

找出第一個(最小的) Element且 k < 它的 Key, 並且回傳之.

找不到的話回傳 this->end()

Definition at line 861 of file SplayTree.h.

template<class Key , class Value >
void meow::SplayTree_Range< Key, Value >::valueOffset ( Value const &  delta)
inline

將所有Element的Value同加上 delta

Definition at line 1065 of file SplayTree.h.

template<class Key , class Value >
void meow::SplayTree_Range< Key, Value >::valueOverride ( Value const &  value)
inline

將所有Element的Value全部設定成value

Definition at line 1074 of file SplayTree.h.


The documentation for this class was generated from the following file: