2016-01-07 08:14:33 +00:00
|
|
|
#pragma once
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
#include <new>
|
2016-05-02 09:57:04 +00:00
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
#include <nall/bit.hpp>
|
2016-05-02 09:57:04 +00:00
|
|
|
#include <nall/function.hpp>
|
2014-02-09 05:59:46 +00:00
|
|
|
#include <nall/maybe.hpp>
|
Update to v094r17 release.
byuu says:
This updates higan to use the new Markup::Node changes. This is a really
big change, and one slight typo anywhere could break certain classes of
games from playing.
I don't have ananke hooked up again yet, so I don't have the ability to
test this much. If anyone with some v094 game folders wouldn't mind
testing, I'd help out a great deal.
I'm most concerned about testing one of each SNES special chip game.
Most notably, systems like the SA-1, HitachiDSP and NEC-DSP were using
the fancier lookups, eg node["rom[0]/name"], which I had to convert to
a rather ugly node["rom"].at(0)["name"], which I'm fairly confident
won't work. I'm going to blame that on the fumes from the shelves I just
stained >.> Might work with node.find("rom[0]/name")(0) though ...? But
so ugly ... ugh.
That aside, this WIP adds the accuracy-PPU inlining, so the accuracy
profile should run around 7.5% faster than before.
2015-05-02 13:05:46 +00:00
|
|
|
#include <nall/memory.hpp>
|
2016-05-02 09:57:04 +00:00
|
|
|
#include <nall/range.hpp>
|
2012-01-26 06:50:09 +00:00
|
|
|
#include <nall/sort.hpp>
|
2016-05-02 09:57:04 +00:00
|
|
|
#include <nall/traits.hpp>
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
namespace nall {
|
2011-10-16 09:44:48 +00:00
|
|
|
|
2016-05-02 09:57:04 +00:00
|
|
|
template<typename T> struct vector_iterator;
|
|
|
|
template<typename T> struct vector_iterator_const;
|
2013-05-02 11:25:45 +00:00
|
|
|
|
2016-05-02 09:57:04 +00:00
|
|
|
template<typename T>
|
|
|
|
struct vector {
|
|
|
|
//core.hpp
|
2013-05-02 11:25:45 +00:00
|
|
|
vector() = default;
|
2016-05-02 09:57:04 +00:00
|
|
|
vector(const initializer_list<T>& values);
|
|
|
|
vector(const vector& source);
|
|
|
|
vector(vector&& source);
|
|
|
|
~vector();
|
|
|
|
|
|
|
|
explicit operator bool() const;
|
|
|
|
auto capacity() const -> uint;
|
|
|
|
auto size() const -> uint;
|
|
|
|
auto data() -> T*;
|
|
|
|
auto data() const -> const T*;
|
|
|
|
|
|
|
|
//assign.hpp
|
|
|
|
auto operator=(const vector& source) -> vector&;
|
|
|
|
auto operator=(vector&& source) -> vector&;
|
|
|
|
|
|
|
|
//memory.hpp
|
|
|
|
auto reset() -> void;
|
|
|
|
auto release() -> T*;
|
|
|
|
|
|
|
|
auto reserveLeft(uint capacity) -> bool;
|
|
|
|
auto reserveRight(uint capacity) -> bool;
|
|
|
|
auto reserve(uint capacity) -> bool { return reserveRight(capacity); }
|
|
|
|
|
|
|
|
auto resizeLeft(uint size, const T& value = T()) -> bool;
|
|
|
|
auto resizeRight(uint size, const T& value = T()) -> bool;
|
|
|
|
auto resize(uint size, const T& value = T()) -> bool { return resizeRight(size, value); }
|
|
|
|
|
|
|
|
//access.hpp
|
|
|
|
alwaysinline auto operator[](uint offset) -> T&;
|
|
|
|
alwaysinline auto operator[](uint offset) const -> const T&;
|
|
|
|
|
|
|
|
alwaysinline auto operator()(uint offset) -> T&;
|
|
|
|
alwaysinline auto operator()(uint offset, const T& value) const -> const T&;
|
|
|
|
|
|
|
|
alwaysinline auto left() -> T&;
|
|
|
|
alwaysinline auto left() const -> const T&;
|
|
|
|
|
|
|
|
alwaysinline auto right() -> T&;
|
|
|
|
alwaysinline auto right() const -> const T&;
|
|
|
|
|
|
|
|
//modify.hpp
|
|
|
|
auto prepend(const T& value) -> void;
|
|
|
|
auto prepend(T&& value) -> void;
|
|
|
|
auto prepend(const vector<T>& values) -> void;
|
|
|
|
auto prepend(vector<T>&& values) -> void;
|
|
|
|
|
|
|
|
auto append(const T& value) -> void;
|
|
|
|
auto append(T&& value) -> void;
|
|
|
|
auto append(const vector<T>& values) -> void;
|
|
|
|
auto append(vector<T>&& values) -> void;
|
|
|
|
|
|
|
|
auto insert(uint offset, const T& value) -> void;
|
|
|
|
|
|
|
|
auto removeLeft(uint length = 1) -> void;
|
|
|
|
auto removeRight(uint length = 1) -> void;
|
|
|
|
auto remove(uint offset, uint length = 1) -> void;
|
|
|
|
|
|
|
|
auto takeLeft() -> T;
|
|
|
|
auto takeRight() -> T;
|
|
|
|
auto take(uint offset) -> T;
|
|
|
|
|
|
|
|
//iterator.hpp
|
|
|
|
auto begin() { return vector_iterator<T>{*this, 0}; }
|
|
|
|
auto end() { return vector_iterator<T>{*this, size()}; }
|
|
|
|
|
|
|
|
auto begin() const { return vector_iterator_const<T>{*this, 0}; }
|
|
|
|
auto end() const { return vector_iterator_const<T>{*this, size()}; }
|
|
|
|
|
|
|
|
//utility.hpp
|
2016-05-16 09:51:12 +00:00
|
|
|
auto sort(const function<bool (const T& lhs, const T& rhs)>& comparator = [](auto& lhs, auto& rhs) { return lhs < rhs; }) -> void;
|
2016-05-02 09:57:04 +00:00
|
|
|
auto find(const T& value) const -> maybe<uint>;
|
|
|
|
|
|
|
|
private:
|
|
|
|
T* _pool = nullptr; //pointer to first initialized element in pool
|
|
|
|
uint _size = 0; //number of initialized elements in pool
|
|
|
|
uint _left = 0; //number of allocated elements free on the left of pool
|
|
|
|
uint _right = 0; //number of allocated elements free on the right of pool
|
2013-05-02 11:25:45 +00:00
|
|
|
};
|
2011-10-16 09:44:48 +00:00
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
2016-05-02 09:57:04 +00:00
|
|
|
|
|
|
|
#include <nall/vector/core.hpp>
|
|
|
|
#include <nall/vector/assign.hpp>
|
|
|
|
#include <nall/vector/memory.hpp>
|
|
|
|
#include <nall/vector/access.hpp>
|
|
|
|
#include <nall/vector/modify.hpp>
|
|
|
|
#include <nall/vector/iterator.hpp>
|
|
|
|
#include <nall/vector/utility.hpp>
|
2016-09-14 11:55:53 +00:00
|
|
|
|
|
|
|
namespace nall {
|
|
|
|
template<typename T> inline auto range(const vector<T>& value) { return range_t{0, (int)value.size(), 1}; }
|
|
|
|
template<typename T> inline auto rrange(const vector<T>& value) { return range_t{(int)value.size() - 1, -1, -1}; }
|
|
|
|
}
|