Skip to content

Commit

Permalink
Rename node to lvalue_type
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryRLee committed Dec 28, 2018
1 parent 10ddc4c commit 120cf49
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions include/fenwick.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace fenwick {
template <class T, class Alloc = std::allocator<T>>
class fenwick {
private:
class node;
class lvalue_type;

public:
/*
Expand Down Expand Up @@ -81,15 +81,15 @@ class fenwick {
/*
* Element access
*/
node operator[](size_type idx) {
return node(*this, idx);
lvalue_type operator[](size_type idx) {
return lvalue_type(*this, idx);
}

const_reference operator[](size_type idx) const {
return data_[idx];
}

node at(size_type idx) {
lvalue_type at(size_type idx) {
check_out_of_range(idx);
return (*this)[idx];
}
Expand All @@ -107,25 +107,25 @@ class fenwick {
}

private:
class node {
class lvalue_type {
public:
node(fenwick& tree, size_type idx) : tree_(tree), idx_(idx) { }
lvalue_type(fenwick& tree, size_type idx) : tree_(tree), idx_(idx) { }

operator value_type() const {
return tree_.data_[idx_];
}

node& operator+=(const_reference delta) {
lvalue_type& operator+=(const_reference delta) {
tree_.update(idx_, delta);
return *this;
}

node& operator-=(const_reference delta) {
lvalue_type& operator-=(const_reference delta) {
tree_.update(idx_, -delta);
return *this;
}

node& operator=(const_reference value) {
lvalue_type& operator=(const_reference value) {
value_type delta = value - tree_.data_[idx_];
return operator+=(delta);
}
Expand All @@ -145,7 +145,7 @@ class fenwick {

void check_out_of_range(size_type idx) const;

friend class node;
friend class lvalue_type;
};

template<class T, class Alloc>
Expand Down

0 comments on commit 120cf49

Please sign in to comment.