fix combinaton

This commit is contained in:
vrd
2023-01-20 23:12:38 +02:00
parent afe6d093a9
commit 9434edbe36
9 changed files with 207 additions and 157 deletions
+31 -19
View File
@@ -1,36 +1,48 @@
#pragma once
#include "common/basicTypes.h"
#include <utility>
#include <ncursesw/ncurses.h>
#include "common/basicTypes.h"
template <class Vec> inline
Vec& operator+=(Vec& lhs, Vec&& rhs) // Combine 2 vectors
{
lhs.reserve(lhs.size() + rhs.size());
/* template <class Vec> */
/* Vec& operator+=(Vec& lhs, Vec&& rhs) // Combine 2 vectors */
/* { */
/* lhs.reserve(lhs.size() + rhs.size()); */
for(auto& el: rhs)
lhs.push_back( std::forward<decltype(el)>(el) );
return lhs;
}
/* for(auto&& el: rhs) */
/* lhs.push_back( std::move(el) ); */
/* return lhs; */
/* } */
template <class Vec> inline
Vec& operator+=(Vec& lhs, const Vec& rhs) // Combine 2 vectors
{
lhs.reserve(lhs.size() + rhs.size());
/* template <class Vec> */
/* Vec& operator+=(Vec& lhs, const Vec& rhs) // Combine 2 vectors */
/* { */
/* lhs.reserve(lhs.size() + rhs.size()); */
for(const auto& el: rhs)
lhs.push_back( std::forward<decltype(el)>(el) );
return lhs;
}
/* for(const auto& el: rhs) */
/* lhs.push_back(el); */
/* return lhs; */
/* } */
template <class Vec> inline
template <class Vec>
void remove(Vec& vec, size_t pos) /* Remove from vector by moving the last element in its place */
{
vec[pos] = vec[vec.size() - 1];
vec.pop_back();
}
inline I32 min(I32 a, I32 b)
{
return a <= b ? a : b;
}
inline I32 max(I32 a, I32 b)
{
return a >= b ? a : b;
}
/* wheather a pad with the given coordinates will be visible */
bool willBeVisible(I16 drawY, I16 drawX, U16 height, U16 width);
/* like pnoutrefresh but pminrow,col are calculated based on width,height and
top left coords, which can be negative (outside the screen) */
void drawpad(WINDOW* pad, I16 drawY, I16 drawX);