mirror of
https://github.com/zeldaret/tp
synced 2026-08-19 22:02:38 -04:00
Various JSystem work (#2383)
* JKernel and JStudio cleanup * JMessage cleanup * JAudio cleanup * JASBNKParser work * functionvalue work * fvb work * J2D and J3D cleanup * steal from tww * J2DPictureEx mostly done * fix build
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#ifndef MSL_ALGORITHM_H_
|
||||
#define MSL_ALGORITHM_H_
|
||||
|
||||
#include <string.h>
|
||||
#include <iterator.h>
|
||||
|
||||
namespace std {
|
||||
@@ -26,11 +25,45 @@ ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, const T
|
||||
return first;
|
||||
}
|
||||
|
||||
template <class ForwardIterator, class T, class Predicate>
|
||||
ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, const T& val, Predicate p) {
|
||||
typedef typename iterator_traits<ForwardIterator>::difference_type difference_type;
|
||||
difference_type len = std::distance(first, last);
|
||||
|
||||
while (len > 0) {
|
||||
ForwardIterator i = first;
|
||||
difference_type step = len / 2;
|
||||
std::advance(i, step);
|
||||
|
||||
if (!p(val, *i)) {
|
||||
first = ++i;
|
||||
len -= step + 1;
|
||||
} else {
|
||||
len = step;
|
||||
}
|
||||
}
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
template <class ForwardIterator, class T>
|
||||
ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, const T& val);
|
||||
|
||||
template<class InputIt, class UnaryPredicate>
|
||||
InputIt find_if(InputIt first, InputIt last, UnaryPredicate p);
|
||||
InputIt find_if(InputIt first, InputIt last, UnaryPredicate p) {
|
||||
while (first != last && !p(*first)) {
|
||||
++first;
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
// fakematch: val should be a const reference, but that breaks JMessage::TResource::toMessageIndex_messageID
|
||||
template<class ForwardIterator, class T>
|
||||
inline ForwardIterator find(ForwardIterator first, ForwardIterator last, T& val) {
|
||||
for (; first != last && *first != val; ++first) {
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
/*
|
||||
template<class OutputIt, class Size, int A2>
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
#define MSL_FUNCTIONAL_H_
|
||||
|
||||
namespace std {
|
||||
template <class T> struct less {};
|
||||
template <class T> struct less {
|
||||
bool operator()(const T& a, const T& b) const {
|
||||
return a < b;
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef MSL_ITERATOR_H_
|
||||
#define MSL_ITERATOR_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
namespace std {
|
||||
struct input_iterator_tag {};
|
||||
struct output_iterator_tag {};
|
||||
|
||||
Reference in New Issue
Block a user