// // intrusive_iterator.hpp // utilities // // Created by Sam Jaffe on 5/10/13. // Copyright (c) 2013 Sam Jaffe. All rights reserved. // #pragma once #include "intrusive_iterator.hpp" template intrusive_iterator::intrusive_iterator(N* node) : node_(node) { } template intrusive_iterator::operator const_intrusive_iterator() const { return node_; } template auto intrusive_iterator::operator*() -> reference { return *(node_->ptr_); } template auto intrusive_iterator::operator*() const -> const_reference { return *(node_->ptr_); } template auto intrusive_iterator::operator->() -> pointer { return node_->ptr_; } template auto intrusive_iterator::operator->() const -> const_pointer { return node_->ptr_; } template intrusive_iterator intrusive_iterator::operator++(int) { intrusive_iterator it{*this}; node_ = node_->next_; return it; } template intrusive_iterator& intrusive_iterator::operator++() { node_ = node_->next_; return *this; } template intrusive_iterator intrusive_iterator::operator--(int) { intrusive_iterator it{*this}; node_ = node_->prev_; return it; } template intrusive_iterator& intrusive_iterator::operator--() { node_ = node_->prev_; return *this; } template N* intrusive_iterator::get() const { return node_; } template bool intrusive_iterator::operator==(const intrusive_iterator& other) const { return node_ == other.node_; } template bool intrusive_iterator::operator!=(const intrusive_iterator& other) const { return node_ != other.node_; } #pragma mark const_intrusive_iterator template const_intrusive_iterator::const_intrusive_iterator(N* node) : node_(node) { } template auto const_intrusive_iterator::operator*() const -> const_reference { return *(node_->ptr_); } template auto const_intrusive_iterator::operator->() const -> const_pointer { return node_->ptr_; } template const_intrusive_iterator const_intrusive_iterator::operator++(int) { const_intrusive_iterator it{*this}; node_ = node_->next_; return it; } template const_intrusive_iterator& const_intrusive_iterator::operator++() { node_ = node_->next_; return *this; } template const_intrusive_iterator const_intrusive_iterator::operator--(int) { const_intrusive_iterator it{*this}; node_ = node_->prev_; return it; } template const_intrusive_iterator& const_intrusive_iterator::operator--() { node_ = node_->prev_; return *this; } template N* const_intrusive_iterator::get() const { return node_; } template bool const_intrusive_iterator::operator==(const const_intrusive_iterator& other) const { return node_ == other.node_; } template bool const_intrusive_iterator::operator!=(const const_intrusive_iterator& other) const { return node_ != other.node_; }