[*] Improved RNG utils
This commit is contained in:
parent
c3e0418e1a
commit
3e3a071e8e
@ -82,9 +82,12 @@ namespace Aurora::RNG
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T &NextIterator(T &begin, T &end)
|
||||
inline T NextIterator(T begin, T end)
|
||||
{
|
||||
return begin + NextIndex(AuUInt(end - begin));
|
||||
auto nextItr = begin;
|
||||
auto uCount = std::distance(begin, end);
|
||||
std::advance(nextItr, NextIndex(uCount));
|
||||
return nextItr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -92,17 +95,23 @@ namespace Aurora::RNG
|
||||
{
|
||||
return pItems[NextIndex(uCount)];
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline T &NextVector(AuList<T> &items)
|
||||
inline auto NextRange(T &items)
|
||||
{
|
||||
return NextArray(items.data(), items.size());
|
||||
return NextIterator(items.begin(), items.end());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T &NextRange(T &items)
|
||||
inline T &NextVector(AuList<T> &items)
|
||||
{
|
||||
return NextIterator(items.begin(), items.end());
|
||||
return *NextRange(items);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline const T &NextVector(const AuList<T> &items)
|
||||
{
|
||||
return *NextRange(items);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -109,14 +109,29 @@ namespace Aurora::RNG
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static auline T &RngVector(AuList<T> &items)
|
||||
inline T RngIterator(T begin, T end)
|
||||
{
|
||||
return RngArray(items.data(), items.size());
|
||||
auto nextItr = begin;
|
||||
auto uCount = std::distance(begin, end);
|
||||
std::advance(nextItr, RngIndex(uCount));
|
||||
return nextItr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static auline T &RngRange(T &items)
|
||||
static auline auto RngRange(T &items)
|
||||
{
|
||||
return RngArray(items.begin(), items.end() - items.begin());
|
||||
return RngIterator(std::begin(items), std::end(items));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static auline T &RngVector(AuList<T> &items)
|
||||
{
|
||||
return *RngRange(items);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static auline const T &RngVector(const AuList<T> &items)
|
||||
{
|
||||
return *RngRange(items);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user