mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-24 15:12:23 +01:00
byuu says: Changelog: - nall/vector rewritten from scratch - higan/audio uses nall/vector instead of raw pointers - higan/sfc/coprocessor/sdd1 updated with new research information - ruby/video/glx and ruby/video/glx2: fuck salt glXSwapIntervalEXT! The big change here is definitely nall/vector. The Windows, OS X and Qt ports won't compile until you change some first/last strings to left/right, but GTK will compile. I'd be really grateful if anyone could stress-test nall/vector. Pretty much everything I do relies on this class. If we introduce a bug, the worst case scenario is my entire SFC game dump database gets corrupted, or the byuu.org server gets compromised. So it's really critical that we test the hell out of this right now. The S-DD1 changes mean you need to update your installation of icarus again. Also, even though the Lunar FMV never really worked on the accuracy core anyway (it didn't initialize the PPU properly), it really won't work now that we emulate the hard-limit of 16MiB for S-DD1 games.
110 lines
3.2 KiB
C++
110 lines
3.2 KiB
C++
#pragma once
|
|
|
|
#include <new>
|
|
|
|
#include <nall/bit.hpp>
|
|
#include <nall/function.hpp>
|
|
#include <nall/maybe.hpp>
|
|
#include <nall/memory.hpp>
|
|
#include <nall/range.hpp>
|
|
#include <nall/sort.hpp>
|
|
#include <nall/traits.hpp>
|
|
|
|
namespace nall {
|
|
|
|
template<typename T> struct vector_iterator;
|
|
template<typename T> struct vector_iterator_const;
|
|
|
|
template<typename T>
|
|
struct vector {
|
|
//core.hpp
|
|
vector() = default;
|
|
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
|
|
auto sort(const function<bool (const T& lhs, const T& rhs)>& comparator = {}) -> void;
|
|
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
|
|
};
|
|
|
|
}
|
|
|
|
#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>
|