本文整理汇总了C++中std::array::end方法的典型用法代码示例。如果您正苦于以下问题:C++ array::end方法的具体用法?C++ array::end怎么用?C++ array::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::array
的用法示例。
在下文中一共展示了array::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: find
static inline bool is_reserved (const char chr) noexcept {
static const std::array<char,18> reserved
{{':' , '/' , '?' , '#' , '[' , ']' , '@',
'!' , '$' , '&' , '\'' , '(' , ')' , '*' , '+' , ',' , ';' , '='}};
return std::find(reserved.begin(), reserved.end(), chr) not_eq reserved.end();
}
示例2: AddSorted
char* AddSorted(unsigned int priority, char value)
{
auto vit = find_venue_value(value);
if (priority == 0)
{
if (vit != venues.end())
remove_venue(*vit);
}
else
{
auto pit = find_venue_priority(priority);
if (pit != venues.end())
{
pit->m_value = value;
if (vit != venues.end())
remove_venue(*vit);
}
else if (pos < 6)
venues[pos++] = Venue(priority, value);
else
return result;
}
// sort from greatest priority to least
std::sort(venues.begin(), venues.end(), std::greater<Venue>());
for (int i = 0; i < venues.size(); ++i)
result[i] = venues[i].m_value;
return result;
}
示例3: AddSorted
char* AddSorted(unsigned int priority, char value)
{
auto vit = find_venue_value(value);
if (vit != venues.end()) // if we found the element then we are either changing its priority or deleting it:
{
auto pit = find_venue_priority(priority);
if (priority == 0)
remove_venue(*vit);
else if (pit != venues.end()) // if we found an element with the same priority,
{
pit->m_value = value; // then change the element's m_value to value and
remove_venue(*vit); // delete old element
}
else // if priority != 0 and there was no duplicate, then just change the priority
vit->m_priority = priority;
}
else if (pos < 6) // if the venue was not found, we are adding a new one
venues[pos++] = Venue(priority, value);
else
return result; // if the element was not found and the array is full, then there is nothing to do
// sort from greatest priority to least
std::sort(venues.begin(), venues.end(), std::greater<Venue>());
for (int i = 0; i < venues.size(); ++i)
result[i] = venues[i].m_value;
return result;
}
示例4: run
int run(std::array<int, PILES>& pile_heights, std::array<int, 5>& basket,
int curr) {
int& res = dp_[calc_dp_index(pile_heights)];
if (res != -1)
return res;
res = curr;
// Check if the basket is full.
auto free_pos = std::find(basket.begin(), basket.end(), -1);
if (free_pos == basket.end())
return res;
// Try which pile it's best to take a candy from.
for (int i = 0; i < PILES; ++i) {
if (pile_heights[i] > 0) {
int candy = piles_[i][pile_heights[i] - 1];
auto candy_pos = std::find(basket.begin(), basket.end(), candy);
if (candy_pos != basket.end()) {
pile_heights[i] -= 1;
*candy_pos = -1;
res = std::max(res, run(pile_heights, basket, curr+1));
*candy_pos = candy;
pile_heights[i] += 1;
} else {
pile_heights[i] -= 1;
*free_pos = candy;
res = std::max(res, run(pile_heights, basket, curr));
*free_pos = -1;
pile_heights[i] += 1;
}
}
}
return res;
}
示例5: writeString
void JsonWriter::writeString(const std::string &string)
{
static const std::string escaped = "\"\\\b\f\n\r\t";
static const std::array<char, 7> escaped_code = {'\"', '\\', 'b', 'f', 'n', 'r', 't'};
out <<'\"';
size_t pos=0, start=0;
for (; pos<string.size(); pos++)
{
//we need to check if special character was been already escaped
if((string[pos] == '\\')
&& (pos+1 < string.size())
&& (std::find(escaped_code.begin(), escaped_code.end(), string[pos+1]) != escaped_code.end()) )
{
pos++; //write unchanged, next simbol also checked
}
else
{
size_t escapedPos = escaped.find(string[pos]);
if (escapedPos != std::string::npos)
{
out.write(string.data()+start, pos - start);
out << '\\' << escaped_code[escapedPos];
start = pos+1;
}
}
}
out.write(string.data()+start, pos - start);
out <<'\"';
}
示例6: setSubMatrixGradient
void setSubMatrixGradient(Eigen::MatrixBase<DerivedA>& dM, const Eigen::MatrixBase<DerivedB>& dM_submatrix,
const std::array<int, NRows>& rows, const std::array<int, NCols>& cols, typename DerivedA::Index M_rows, typename DerivedA::Index q_start, typename DerivedA::Index q_subvector_size) {
if (q_subvector_size == Eigen::Dynamic) {
q_subvector_size = dM.cols() - q_start;
}
int index = 0;
for (typename std::array<int, NCols>::const_iterator col = cols.begin(); col != cols.end(); ++col) {
for (typename std::array<int, NRows>::const_iterator row = rows.begin(); row != rows.end(); ++row) {
dM.template block<1, QSubvectorSize> ((*row) + (*col) * M_rows, q_start, 1, q_subvector_size) = dM_submatrix.row(index++);
}
}
}
示例7: BadKeyLength
void CAST256::setKey(const BytesVector &key)
{
const uint8_t keylen = key.size();
constexpr std::array<uint8_t, 5> allowed_key_lengths = {{16, 20, 24, 28, 32}};
const auto it = std::find(allowed_key_lengths.begin(), allowed_key_lengths.end(), keylen);
if (it == allowed_key_lengths.end())
{
throw BadKeyLength("Your key length has to be of length 16, 20, 24, 28 or 32 bytes.", keylen);
}
// Pad the key with 0 to get 256 bits length.
this->key = Padding::zeros(key, 32);
}
示例8:
BoolTagFilter::BoolTagFilter(const std::string & key, bool value) :
KeyMultiValueTagFilter(key),
m_Value(value)
{
if (m_Value)
{
const std::array<std::string, 5> s{ { "True", "true", "Yes", "yes", "1" } };
KeyMultiValueTagFilter::setValues(s.begin(), s.end());
}
else
{
const std::array<std::string, 5> s{ { "False", "false", "No", "no", "0" } };
KeyMultiValueTagFilter::setValues(s.begin(), s.end());
}
}
示例9: release
void release(const MidiEvent& evt)
{
int note_no = MidiEventUtils::getNote(evt);
auto note = std::find_if(
notes.begin(),
notes.end(),
[note_no](blit_saw_oscillator_note& n) { return n.note_no == note_no; });
if (note != notes.end())
{
// note off
note->note_no = -1;
}
}
示例10: mManager
OpenALStream(AudioManagerImpl *manager, MidiSong *song)
: mManager(manager), mSong(song), mQuit(false), mSource(0)
, mBufferIdx(0), mSampleRate(0)
{
// Using std::fill for mBuffers since VS2013 doesn't support mBuffers{0}.
std::fill(mBuffers.begin(), mBuffers.end(), 0);
}
示例11: TiledRange
TArray4s::trange_type
InputData::trange(const Spin s1, const Spin s2, const RangeOV ov1, const RangeOV ov2, const RangeOV ov3, const RangeOV ov4) const {
const obs_mosym& spin1 = (s1 == alpha ? obs_mosym_alpha_ : obs_mosym_beta_);
const std::size_t& nocc1 = (s1 == alpha ? nocc_act_alpha_ : nocc_act_beta_);
const obs_mosym& spin2 = (s2 == alpha ? obs_mosym_alpha_ : obs_mosym_beta_);
const std::size_t& nocc2 = (s2 == alpha ? nocc_act_alpha_ : nocc_act_beta_);
const std::size_t first1 = (ov1 == occ ? 0 : nocc1);
const std::size_t last1 = (ov1 == occ ? nocc1 : nmo_);
const std::size_t first2 = (ov2 == occ ? 0 : nocc2);
const std::size_t last2 = (ov2 == occ ? nocc2 : nmo_);
const std::size_t first3 = (ov3 == occ ? 0 : nocc1);
const std::size_t last3 = (ov3 == occ ? nocc1 : nmo_);
const std::size_t first4 = (ov4 == occ ? 0 : nocc2);
const std::size_t last4 = (ov4 == occ ? nocc2 : nmo_);
const std::array<TiledArray::TiledRange1, 4> tr_list = {{
make_trange1(spin1.begin(), spin1.begin() + first1, spin1.begin() + last1),
make_trange1(spin2.begin(), spin2.begin() + first2, spin2.begin() + last2),
make_trange1(spin1.begin(), spin1.begin() + first3, spin1.begin() + last3),
make_trange1(spin2.begin(), spin2.begin() + first4, spin2.begin() + last4)
}
};
return TiledArray::TiledRange(tr_list.begin(), tr_list.end());
}
示例12: max_element
static
inline
T
max(const std::array<T, DIM>& arr)
{
return std::max_element(arr.begin(), arr.end());
}
示例13: find
bool Arm64FPRCache::IsCalleeSaved(ARM64Reg reg)
{
static constexpr std::array<ARM64Reg, 9> callee_regs{{
Q8,
Q9,
Q10,
Q11,
Q12,
Q13,
Q14,
Q15,
INVALID_REG,
}};
return std::find(callee_regs.begin(), callee_regs.end(), reg) != callee_regs.end();
}
示例14: perform_and_exit
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
args.parse_arguments(COMMAND_STRUCTURE);
if (args.command_arguments.empty())
{
print_usage();
Checks::exit_success(VCPKG_LINE_INFO);
}
const auto& topic = args.command_arguments[0];
if (topic == "triplet" || topic == "triplets" || topic == "triple")
{
help_topic_valid_triplet(paths);
Checks::exit_success(VCPKG_LINE_INFO);
}
auto it_topic = Util::find_if(topics, [&](const Topic& t) { return t.name == topic; });
if (it_topic != topics.end())
{
it_topic->print(paths);
Checks::exit_success(VCPKG_LINE_INFO);
}
System::println(System::Color::error, "Error: unknown topic %s", topic);
help_topics(paths);
Checks::exit_fail(VCPKG_LINE_INFO);
}
示例15:
inline bp::list v_to_l(std::array<T, dim> vector) {
bp::list list;
for (auto iter = vector.begin(); iter != vector.end(); ++iter) {
list.append(*iter);
}
return list;
}