16 #ifndef EMP_INT_PACK_H 17 #define EMP_INT_PACK_H 30 template <
bool DONE,
int START,
int END,
int STEP,
int... VALS>
32 static constexpr
int NEXT = START + STEP;
35 template <
int START,
int END,
int STEP,
int... VALS>
36 struct ip_range <true, START, END, STEP, VALS...> {
40 template <
typename T1,
typename T2>
struct ip_concat;
41 template <
int... T1s,
int... T2s>
46 template <
typename T_IN,
typename T_OUT=IntPack<>,
bool DONE=false,
int VERSION=0>
50 template <
int V>
using out_pbin =
typename T_OUT::template push_back_if_not<T_IN::first, V>;
58 template <
typename T_IN,
typename T_OUT,
int VERSION>
59 struct ip_loop<T_IN, T_OUT, true, VERSION> {
60 template <
int V>
using pop_val =
typename T_OUT::template append<T_IN>;
62 template <
typename T_OUT,
int VERSION>
65 template <
int V>
using remove = T_OUT;
66 template <
int V>
using uniq = T_OUT;
70 template <
int V,
int X,
typename T>
72 using result =
typename T::template push<V>;
73 using back =
typename T::template push_back<V>;
75 template <
int V,
typename T>
96 template <
typename T_IN,
typename T_OUT>
98 template <
int V>
using spop =
typename T_IN::template pop_val<V>;
102 template <
typename T_OUT>
104 template <
int V>
using sort = T_OUT;
116 template <
int START,
int END,
int STEP=1>
120 template <
int V1,
int... Vs>
122 static constexpr
int first = V1;
135 constexpr
static bool Has(
int V) {
return (V==V1) |
pop::Has(V); }
136 constexpr
static int Count(
int V) {
return pop::Count(V) + (V==V1); }
137 constexpr
static int GetID(
int V) {
return (V==V1) ? 0 : (1+pop::GetID(V)); }
139 constexpr
static int SIZE = 1+
sizeof...(Vs);
140 constexpr
static int GetSize() {
return SIZE; }
142 constexpr
static bool IsEmpty() {
return false; }
171 constexpr
static bool Has(
int) {
return false; }
172 constexpr
static int Count(
int) {
return 0; }
173 constexpr
static int GetID(
int V) {
return -100000; }
175 constexpr
static int SIZE = 0;
178 constexpr
static bool IsEmpty() {
return true; }
181 constexpr
static int Sum() {
return 0; }
183 constexpr
static int Min(
int cap) {
return cap; }
184 constexpr
static int Max(
int floor) {
return floor; }
186 static void PrintInts(std::ostream & os=std::cout) { ; }
static constexpr int Sum()
Definition: IntPack.h:181
static constexpr int NEXT
Definition: IntPack.h:32
constexpr T Min(T in1)
Min of only one element is that element itself!
Definition: math.h:50
typename T_IN::pop in_pop
Definition: IntPack.h:49
typename T_OUT::template push_back_if_not< T_IN::first, V > out_pbin
Definition: IntPack.h:50
static constexpr int GetSize()
Definition: IntPack.h:140
typename T_OUT::template append< T_IN > pop_val
Definition: IntPack.h:60
static constexpr bool IsUnique()
Definition: IntPack.h:179
static void PrintInts(std::ostream &os=std::cout)
Definition: IntPack.h:152
typename internal::ip_push_if_not< V, X, IntPack<>>::back push_back_if_not
Definition: IntPack.h:166
T_OUT sort
Definition: IntPack.h:104
static constexpr int GetID(int V)
Definition: IntPack.h:173
typename pnext< V, T_IN::first==V >::template pop_val< V > pop_val
Definition: IntPack.h:54
static constexpr bool IsEmpty()
Definition: IntPack.h:142
static constexpr bool IsUnique()
Definition: IntPack.h:143
typename snext< V >::template sort< spop< V >::Min(T_IN::first) > sort
Definition: IntPack.h:100
T back
Definition: IntPack.h:78
static constexpr int Max(int floor)
Definition: IntPack.h:149
reverse< Usort< T > > RUsort
Definition: IntPack.h:196
typename internal::ip_push_if_not< V, X, this_t >::back push_back_if_not
Definition: IntPack.h:130
static constexpr int GetID(int V)
Definition: IntPack.h:137
Definition: IntPack.h:160
static constexpr int Min(int cap)
Definition: IntPack.h:147
static constexpr int Min()
Definition: IntPack.h:148
typename ip_sort_impl< ip, IntPack<>>::template sort< ip::Min()> result
Definition: IntPack.h:110
static constexpr bool Has(int V)
Definition: IntPack.h:135
T result
Definition: IntPack.h:77
T Product(const emp::vector< T > &v)
Multiply all of the contents of a vector.
Definition: vector_utils.h:86
static constexpr int Min(int cap)
Definition: IntPack.h:183
typename internal::ip_loop< this_t, IntPack<>, false, 3 >::template remove< V > remove
Definition: IntPack.h:132
typename internal::ip_loop< this_t, IntPack<>, false, 2 >::template pop_val< V > pop_val
Definition: IntPack.h:131
typename internal::ip_push_if_not< V, X, IntPack<>>::result push_if_not
Definition: IntPack.h:165
typename ip_loop< IntPack< V1, Vs... >, IntPack<>, false, 1 >::template uniq< V1+1 > result
Definition: IntPack.h:91
typename T::template push_back< V > back
Definition: IntPack.h:73
typename T_IN::template pop_val< V > spop
Definition: IntPack.h:98
T append
Definition: IntPack.h:169
typename internal::ip_reverse< T >::result reverse
Definition: IntPack.h:190
typename pnext< V >::template remove< V > remove
Definition: IntPack.h:55
typename internal::ip_concat< this_t, T >::result append
Definition: IntPack.h:133
typename internal::ip_range<(START >=END), START, END, STEP >::type IntPackRange
Definition: IntPack.h:117
T_OUT uniq
Definition: IntPack.h:66
static constexpr int Product()
Definition: IntPack.h:182
static constexpr bool Has(int)
Definition: IntPack.h:171
constexpr T Max(T in1)
Max of only one element is that element itself!
Definition: math.h:61
uniq< sort< T > > Usort
Definition: IntPack.h:195
bool Has(const MAP_T &in_map, const KEY_T &key)
Take any map type, and run find to determine if a key is present.
Definition: map_utils.h:21
static constexpr int GetSize()
Definition: IntPack.h:176
Definition: IntPack.h:121
static constexpr int Max(int floor)
Definition: IntPack.h:184
typename internal::ip_uniq< T >::result uniq
Definition: IntPack.h:191
T_OUT pop_val
Definition: IntPack.h:64
typename T::template push< V > result
Definition: IntPack.h:72
If we are in emscripten, make sure to include the header.
Definition: array.h:37
static constexpr int Count(int V)
Definition: IntPack.h:136
reverse< sort< T > > Rsort
Definition: IntPack.h:194
static constexpr int Sum()
Definition: IntPack.h:145
typename pnext< V >::template uniq< T_IN::first > uniq
Definition: IntPack.h:56
static constexpr int Max()
Definition: IntPack.h:150
typename internal::ip_sort< T >::result sort
Definition: IntPack.h:193
static constexpr int Count(int)
Definition: IntPack.h:172
Definition: IntPack.h:107
static void PrintInts(std::ostream &os=std::cout)
Definition: IntPack.h:186
typename internal::ip_push_if_not< V, X, this_t >::result push_if_not
Definition: IntPack.h:129
typename ip_reverse< IntPack< Vs... > >::result::template push_back< V1 > result
Definition: IntPack.h:84
typename ip_range<(NEXT >=END), NEXT, END, STEP, VALS..., START >::type type
Definition: IntPack.h:33
static constexpr bool IsEmpty()
Definition: IntPack.h:178
constexpr size_t GetSize(T(&)[N])
Determine the size of a built-in array.
Definition: functions.h:81
static constexpr int Product()
Definition: IntPack.h:146
std::enable_if<!emp::is_ptr_type< typename C::value_type >::value &&std::is_scalar< typename C::value_type >::value, typename C::value_type >::type Sum(C &elements)
Definition: stats.h:33