本文整理汇总了C++中array::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ array::begin方法的具体用法?C++ array::begin怎么用?C++ array::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类array
的用法示例。
在下文中一共展示了array::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copy_out
void copy_out(array<T, S>& out, const array<J, D>& in)
{
CHECK(out.length() <= in.length(), erange);
typename array<J, D>::const_iterator it_src = in.begin();
typename array<T, S>::iterator it_end = out.end();
typename array<T, S>::iterator it = out.begin();
while (it != it_end) *it++ = *it_src++;
}
示例2: anagram
void anagram(array<string,sz> &arrStr){
// for_each( arrStr.begin(), arrStr.end(), myStrSort);
for( auto & str : arrStr )
sort( str.begin(), str.end() );
sort( arrStr.begin(), arrStr.end() );
std::cout << "\nAfter in-place sorting, arrStr contains:\n\n";
for ( auto it = arrStr.begin(); it != arrStr.end(); ++it )
std::cout << ' ' << *it;
std::cout << endl;
}
示例3: con_add_buffer_line
static void con_add_buffer_line(const con_priority priority, const char *const buffer, const size_t len)
{
/* shift con_buffer for one line */
std::move(std::next(con_buffer.begin()), con_buffer.end(), con_buffer.begin());
console_buffer &c = con_buffer.back();
c.priority=priority;
size_t copy = std::min(len, CON_LINE_LENGTH - 1);
c.line[copy] = 0;
memcpy(&c.line,buffer, copy);
}
示例4: copy_n
void copy_n(array<T, S>& out, const array<J, D>& in, int n)
{
/* TODO: would be nice
CHECK(out.length() <= in.length(), erange);
loops::loop_n<loops::assign_copy_class<T, J> >
(out.derived(), in.derived(), n);
*/
typename array<J, D>::const_iterator it_src = in.begin();
typename array<T, S>::iterator it = out.begin();
while (n--) *it++ = *it_src++;
}
示例5:
BOOST_AUTO_TEST_CASE_TEMPLATE( real_valued, T, real_types )
{
array<T,3> x = {{ 1, 2, 3 }};
array<T,3> y = {{ 4, 5, 6 }};
blas::swap(x.size(), x.c_array(), 1, y.c_array(), 1);
const array<T,3> x_expected = {{ 4, 5, 6 }};
const array<T,3> y_expected = {{ 1, 2, 3 }};
BOOST_CHECK_EQUAL_COLLECTIONS(
x.begin(), x.end(), x_expected.begin(), x_expected.end());
BOOST_CHECK_EQUAL_COLLECTIONS(
y.begin(), y.end(), y_expected.begin(), y_expected.end());
}
示例6: name_copy
bool name_copy(array<u8>& d, const char* s) {
const char* p = s;
const char* e = sz_find_last_or_end(s, '.');
if (!d.set_size(e - s + 1))
return false;
memcpy(d.begin(), s, e - s);
d[e - s] = '\0';
_strlwr_s((char*)d.begin(), d.size());
return true;
}
示例7: main
int main() {
size_t tCase;
int tmp;
in >> tCase;
while (tCase--) {
MaxResult = 0;
SequenceNumber.clear();
fill(DynamicMemory.begin(), DynamicMemory.end(), -1);
in >> Seqnum;
for (size_t i = 0; i < Seqnum;i ++) {
in >> tmp;
SequenceNumber.push_back(tmp);
}
for (size_t i = 0; i < Seqnum; i++) {
if (DynamicMemory[i] == -1) LIS(SequenceNumber, i);
}
for (size_t i = 0; i < Seqnum; i++) {
if (DynamicMemory[i] == -1) break;
if (DynamicMemory[i] > MaxResult) {
MaxResult = DynamicMemory[i];
}
}
cout << MaxResult << endl;
}
return 0;
}
示例8: process
/** Evaluates and executes a dvisvgm special statement.
* @param[in] prefix special prefix read by the SpecialManager
* @param[in] is the special statement is read from this stream
* @param[in] actions object providing the actions that can be performed by the SpecialHandler */
bool DvisvgmSpecialHandler::process (const string &prefix, istream &is, SpecialActions &actions) {
struct Command {
const char *name;
void (DvisvgmSpecialHandler::*handler)(InputReader&, SpecialActions&);
};
constexpr array<Command, 7> commands {{
{"raw", &DvisvgmSpecialHandler::processRaw},
{"rawdef", &DvisvgmSpecialHandler::processRawDef},
{"rawset", &DvisvgmSpecialHandler::processRawSet},
{"endrawset", &DvisvgmSpecialHandler::processEndRawSet},
{"rawput", &DvisvgmSpecialHandler::processRawPut},
{"bbox", &DvisvgmSpecialHandler::processBBox},
{"img", &DvisvgmSpecialHandler::processImg}
}};
StreamInputReader ir(is);
const string cmdstr = ir.getWord();
auto it = find_if(commands.begin(), commands.end(), [&](const Command &cmd) {
return cmd.name == cmdstr;
});
if (it != commands.end()) {
ir.skipSpace();
(this->*it->handler)(ir, actions);
}
return true;
}
示例9: main
int main() {
int N, M, total=0;
cin >> N >> M;
//scanf("%d %d", &N, &M);
fill_n(childSize.begin(), N+1, 1);
while (M--) {
int from, to;
cin >> from >> to;
//scanf("%d %d", &from, &to);
if (from < to) {
int temp = from;
from = to;
to = temp;
}
tree[from].push_back(to);
}
for (int i=N; i!=0; i--) {
update(i);
}
for (int i=N; i!=0; i--) {
if (0 == childSize[i]%2) {
total += tree[i].size();
seperate(i);
}
}
cout << total << endl;
return 0;
}
示例10: copy
void copy(array<T, S>& out, const T& val,
types::term as_element)
{
typename array<T, S>::iterator it_end = out.end();
typename array<T, S>::iterator it = out.begin();
while (it != it_end)
*(it++) = (val);
}
示例11: buildSuffixArray
void buildSuffixArray()
{
layout = 0;
for (int i = 0; i < n; i++)
order[i] = n - 1 - i;
stable_sort(order.begin(), order.begin() + n, [&] (int a, int b) { return s[a] < s[b]; });
for (int i = 0; i < n; i++)
{
sufArray[layout][i] = order[i];
classes[i] = s[i];
}
for (int len = 1; len < n; len *= 2)
{
for (int i = 0; i < n; tempClasses[i] = classes[i], i++);
for (int i = 0; i < n; i++)
{
classes[sufArray[layout][i]] = i > 0 &&
tempClasses[sufArray[layout][i - 1]] == tempClasses[sufArray[layout][i]] &&
sufArray[layout][i - 1] + len < n &&
tempClasses[sufArray[layout][i - 1] + len / 2] == tempClasses[sufArray[layout][i] + len / 2] ?
classes[sufArray[layout][i - 1]] : i;
}
for (int i = 0; i < n; i++)
{
counter[i] = i;
sufArray[layout + 1][i] = sufArray[layout][i];
}
for (int i = 0; i < n; i++)
{
int s1 = sufArray[layout][i] - len;
if (s1 >= 0)
sufArray[layout + 1][counter[classes[s1]]++] = s1;
}
layout++;
}
}
示例12: stop
void stop() {
if ( !started_) return;
started_ = false;
sock_.close();
ptr self = shared_from_this();
array::iterator it = std::find(clients.begin(), clients.end(), self);
clients.erase(it);
update_clients_changed();
}
示例13:
bool operator==(const array& _ar)const{
if(size()!=_ar.size())return false;
iterator itr1=begin(),itr2=_ar.begin();
while(itr1!=end()){
if((*itr1)!=(*itr2))return false;
++itr1;
++itr2;
}
return true;
}
示例14: copy
void copy(const array<T>& _ar){
assign(_ar.size());
const_iterator citr=_ar.begin(),cenditr=_ar.end();
iterator itr=begin();
while(citr!=cenditr){
(*itr)=(*citr);
++citr;
++itr;
}
}
示例15: main
int main(int argc, char** argv)
{
std::cout << "arrStr contains:\n";
for ( auto it = arrStr.begin(); it != arrStr.end(); ++it )
std::cout << ' ' << *it;
std::cout << '\n';
sortAnagram(arrStr);
anagram(arrStr);
return 0;
}