susumu.yata
null+****@clear*****
Mon Aug 11 11:24:57 JST 2014
susumu.yata 2014-08-11 11:24:57 +0900 (Mon, 11 Aug 2014) New Revision: 9205f446be38fd92c05aef4d0112dbd064db99f5 https://github.com/groonga/grnxx/commit/9205f446be38fd92c05aef4d0112dbd064db99f5 Message: Add swap() to Array and ArrayRef. Modified files: include/grnxx/array.hpp Modified: include/grnxx/array.hpp (+20 -0) =================================================================== --- include/grnxx/array.hpp 2014-08-11 11:22:49 +0900 (8b01db8) +++ include/grnxx/array.hpp 2014-08-11 11:24:57 +0900 (96605b6) @@ -122,6 +122,10 @@ class ArrayRef { return size_; } + void swap(Int i, Int j) { + std::swap(values_[i], values_[j]); + } + private: Value *values_; Int size_; @@ -275,6 +279,10 @@ class Array { values_.pop_back(); } + void swap(Int i, Int j) { + std::swap(values_[i], values_[j]); + } + private: std::vector<Value> values_; }; @@ -480,6 +488,12 @@ class ArrayRef<Bool> { return static_cast<Int>(size_); } + void swap(Int i, Int j) { + Bool temp = get(i); + set(i, get(j)); + set(j, temp); + } + private: uint64_t *blocks_; struct { @@ -634,6 +648,12 @@ class Array<Bool> { --size_; } + void swap(Int i, Int j) { + Bool temp = get(i); + set(i, get(j)); + set(j, temp); + } + private: Array<uint64_t> blocks_; Int size_; -------------- next part -------------- HTML����������������������������...下載