You can use std::map mapping (index, insertion-time) pairs for values ββwhere the insertion time is an integer "auto-increment" (in terms of SQL). The order in pairs should be
(i, t) < (i*, t*)
then and only then
i < i* or t > t*
In code:
struct lt { bool operator()(std::pair<size_t, size_t> const &x, std::pair<size_t, size_t> const &y) { return x.first < y.first || x.second > y.second; } }; typedef std::map<std::pair<size_t, size_t>, int, lt> array_like; void insert(array_like &a, int value, size_t i) { a[std::make_pair(i, a.size())] = value; }
Fred foo
source share