| 1 |
pcg |
1.1 |
#ifndef RXVT_VEC_H |
| 2 |
|
|
#define RXVT_VEC_H |
| 3 |
|
|
|
| 4 |
|
|
template<typename T> static inline T min (T a, long b) { return a < b ? a : b; } |
| 5 |
|
|
template<typename T> static inline T max (T a, long b) { return a > b ? a : b; } |
| 6 |
|
|
|
| 7 |
|
|
#include <cstring> |
| 8 |
|
|
#include "simplevec.h" |
| 9 |
|
|
|
| 10 |
|
|
#if 0 |
| 11 |
|
|
template<typename T> |
| 12 |
|
|
struct rxvt_vec : simplevec<void *> { |
| 13 |
|
|
typedef T *iterator; |
| 14 |
|
|
|
| 15 |
|
|
void push_back (T d) { simplevec<void *>::push_back ((void *)d); } |
| 16 |
|
|
T pop_back () { return (T*)simplevec<void *>::pop_back (); } |
| 17 |
|
|
void erase (int i) { erase (begin () + i); } |
| 18 |
|
|
void erase (iterator i) { simplevec<void *>::erase ((void **)i); } |
| 19 |
|
|
iterator begin () const { return (iterator)simplevec<void *>::begin (); } |
| 20 |
|
|
iterator end () const { return (iterator)simplevec<void *>::end (); } |
| 21 |
|
|
T &operator [](int i) { return *(T *)(&((*(simplevec<void *> *)this)[i])); } |
| 22 |
|
|
const T &operator [](int i) const { return *(const T *)(&((*(const simplevec<void *> *)this)[i])); } |
| 23 |
|
|
}; |
| 24 |
|
|
#endif |
| 25 |
|
|
|
| 26 |
|
|
template <typename I, typename T> |
| 27 |
|
|
I find(I first, I last, const T& value) |
| 28 |
|
|
{ |
| 29 |
|
|
while (first != last && *first != value) |
| 30 |
|
|
++first; |
| 31 |
|
|
|
| 32 |
|
|
return first; |
| 33 |
|
|
} |
| 34 |
|
|
|
| 35 |
|
|
#endif |