2016-04-03 00:08:31 +08:00
|
|
|
/*
|
|
|
|
* StockMapIterator.h
|
|
|
|
*
|
|
|
|
* Created on: 2015年2月8日
|
2016-04-14 01:36:53 +08:00
|
|
|
* Author: fasiondog
|
2016-04-03 00:08:31 +08:00
|
|
|
*/
|
|
|
|
|
2019-08-03 21:53:24 +08:00
|
|
|
#pragma once
|
2016-04-03 00:08:31 +08:00
|
|
|
#ifndef STOCKMAPITERATOR_H_
|
|
|
|
#define STOCKMAPITERATOR_H_
|
|
|
|
|
|
|
|
#include <iterator>
|
|
|
|
#include "Stock.h"
|
|
|
|
|
|
|
|
namespace hku {
|
|
|
|
|
|
|
|
class StockMapIterator {
|
|
|
|
public:
|
|
|
|
typedef unordered_map<string, Stock> stock_map_t;
|
|
|
|
typedef Stock value_type;
|
|
|
|
typedef Stock* pointer;
|
|
|
|
typedef const Stock& reference;
|
|
|
|
typedef stock_map_t::const_iterator::difference_type difference_type;
|
|
|
|
typedef std::input_iterator_tag iterator_category;
|
|
|
|
|
|
|
|
StockMapIterator() {}
|
2020-11-02 23:47:15 +08:00
|
|
|
|
|
|
|
// cppcheck-suppress noExplicitConstructor
|
2016-04-03 00:08:31 +08:00
|
|
|
StockMapIterator(const stock_map_t::const_iterator& iter) : m_iter(iter) {}
|
2020-11-02 23:47:15 +08:00
|
|
|
|
2016-04-03 00:08:31 +08:00
|
|
|
StockMapIterator(const StockMapIterator& iter) : m_iter(iter.m_iter) {}
|
|
|
|
|
2021-01-27 22:23:49 +08:00
|
|
|
StockMapIterator& operator=(const StockMapIterator& iter) {
|
|
|
|
HKU_IF_RETURN(this == &iter, *this);
|
|
|
|
m_iter = iter.m_iter;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-04-03 00:08:31 +08:00
|
|
|
StockMapIterator& operator++() {
|
|
|
|
++m_iter;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
const StockMapIterator operator++(int) {
|
|
|
|
auto old_iter = m_iter;
|
|
|
|
++m_iter;
|
|
|
|
return StockMapIterator(old_iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const StockMapIterator& iter) const {
|
|
|
|
return m_iter == iter.m_iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const StockMapIterator& iter) const {
|
|
|
|
return m_iter != iter.m_iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Stock& operator*() const {
|
|
|
|
return m_iter->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Stock* const operator->() const {
|
|
|
|
return &(m_iter->second);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
stock_map_t::const_iterator m_iter;
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace hku */
|
|
|
|
|
|
|
|
#endif /* STOCKMAPITERATOR_H_ */
|