本文整理汇总了C++中copy函数的典型用法代码示例。如果您正苦于以下问题:C++ copy函数的具体用法?C++ copy怎么用?C++ copy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了copy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: _substract
/* basic a - b; where both a and b are positive numbers */
slist* _substract(slist *a, slist *b)
{
slist *diff = NULL;
if (a == NULL && b == NULL) {
diff = insert(diff, 0);
return (diff);
}
if (a == NULL) {
diff = copy(b);
diff = push_back(diff, -1);
return (diff);
}
if (b == NULL) {
return (copy(a));
}
unsigned int carry = 0;
unsigned int negative = 0;
slist *g = greater(a, b); /* greater pointer */
slist *l = NULL; /* lesser pointer */
if (g == NULL) { /* both are equal */
diff = insert(diff, 0);
return (diff);
} else if (g == a) {
l = b;
} else {
l = a;
negative = 1;
}
while (g && l) {
if ((g->data - carry) >= l->data) {
diff = push_back(diff, (g->data - carry - l->data));
carry = 0;
} else {
diff = push_back(diff, (10 + g->data - carry - l->data));
carry = 1;
}
g = g->next;
l = l->next;
}
if (g == NULL && l == NULL) {
/* diff has correct result */
} else if (l == NULL) {
while (g) {
diff = push_back(diff, g->data - carry);
carry = 0;
}
} else if (g == NULL) {
/* something went wrong, we shouldn't have been here */
/* err!!? */
} else {
/* not possible; */
}
if (negative)
diff = push_back(diff, -1);
return (diff);
}
开发者ID:syedahsan,项目名称:codes,代码行数:66,代码来源:mathematical_operations_long_numbers_ll.c
示例2: copy
word::word(const word& other)
{
copy(other);
}
开发者ID:NataliaAlonso,项目名称:CS8,代码行数:4,代码来源:word.cpp
示例3: copy
void DSA_controller::GetPattern(string ith_Pattern)
{
copy(ith_Pattern.begin(),ith_Pattern.end(),back_inserter(tempPattern));
reverse(tempPattern.begin(), tempPattern.end());
}
开发者ID:gmfricke,项目名称:iAnt-ARGoS,代码行数:5,代码来源:DSA_controller.cpp
示例4: copy
CMfxTrack::CMfxTrack( const CMfxTrack& rhs )
{
copy( rhs );
}
开发者ID:agangzz,项目名称:foo_midi,代码行数:4,代码来源:MfxTrack.cpp
示例5: copy
CityWeather &
CityWeather::operator=(const CityWeather & other)
{
return copy( other );
}
开发者ID:pkt,项目名称:plasma-widget-yawp-0.4.1-el,代码行数:5,代码来源:yawpday.cpp
示例6: copy
void TextEvent::setType(int type){
ProtocolEntry *toCopy = copy();
_type = type;
protocol(toCopy, this);
}
开发者ID:HassanBouchiba,项目名称:MidiEditor,代码行数:5,代码来源:TextEvent.cpp
示例7: copy
std::string field::value() const
{
std::string s;
copy(_payload.begin(), _payload.end(), back_inserter(s));
return s;
}
开发者ID:christophgysin,项目名称:addp,代码行数:6,代码来源:field.cpp
示例8: return
CCFiniteTimeAction * CCActionInstant::reverse() {
return (CCFiniteTimeAction*) (copy()->autorelease());
}
开发者ID:BellyWong,项目名称:CutCutCut2dx,代码行数:3,代码来源:CCActionInstant.cpp
示例9: copy
// copy constructor
Exception::Exception (const Exception & xpt)
{
copy (xpt);
}
开发者ID:mik0001,项目名称:Blender,代码行数:5,代码来源:Exception.cpp
示例10: check
template<class R> const View<T>& operator =(const R& r) const {
check(boost::size(r) == this->size(), "can't assign range " + str(r) +
" to view " + str(*this));
copy(r, *this);
return *this;
}
开发者ID:Neuralreadingsystems,项目名称:rnnlib,代码行数:6,代码来源:Container.hpp
示例11:
CCLuaValue& CCLuaValue::operator=(const CCLuaValue& rhs)
{
if (this != &rhs) copy(rhs);
return *this;
}
开发者ID:zhanhuai1,项目名称:code1,代码行数:5,代码来源:CCLuaEngine.cpp
示例12: copy
CCLuaValue::CCLuaValue(const CCLuaValue& rhs)
{
copy(rhs);
}
开发者ID:zhanhuai1,项目名称:code1,代码行数:4,代码来源:CCLuaEngine.cpp
示例13: getOption
//.........这里部分代码省略.........
// Lagrange multipliers for the nonlinear constraints that aren't eliminated
lam_f2 = ssym("lam_f2",nf2);
if(verbose_){
cout << "Allocated intermediate variables." << endl;
}
// Lagrange multipliers for constraints
lam_g = vertcat(lam_v_eq,lam_f2);
// Lagrangian function
SX lag = f + inner_prod(lam_x,x);
if(!f2.empty()) lag += inner_prod(lam_f2,f2);
if(!v.empty()) lag += inner_prod(lam_v_eq,v_def);
// Gradient of the Lagrangian
SX lgrad = casadi::gradient(lag,x);
if(!v.empty()) lgrad -= vertcat(SX::zeros(nu),lam_v_eq); // Put here to ensure that lgrad is of the form "h_extended -v_extended"
makeDense(lgrad);
if(verbose_){
cout << "Generated the gradient of the Lagrangian." << endl;
}
// Condensed gradient of the Lagrangian
f1 = lgrad[Slice(0,nu)];
nf1 = nu;
// Gradient of h
SX v_eq_grad = lgrad[Slice(nu,nu+nv)];
// Reverse lam_v_eq and v_eq_grad
SX v_eq_grad_reversed = v_eq_grad;
copy(v_eq_grad.rbegin(),v_eq_grad.rend(),v_eq_grad_reversed.begin());
SX lam_v_eq_reversed = lam_v_eq;
copy(lam_v_eq.rbegin(),lam_v_eq.rend(),lam_v_eq_reversed.begin());
// Augment h and lam_v_eq
v_eq.append(v_eq_grad_reversed);
v.append(lam_v_eq_reversed);
}
// Residual function G
SXVector G_in(G_NUM_IN);
G_in[G_X] = x;
G_in[G_LAM_X] = lam_x;
G_in[G_LAM_G] = lam_g;
SXVector G_out(G_NUM_OUT);
G_out[G_D] = v_eq;
G_out[G_G] = g;
G_out[G_F] = f;
rfcn_ = SXFunction(G_in,G_out);
rfcn_.setOption("number_of_fwd_dir",0);
rfcn_.setOption("number_of_adj_dir",0);
rfcn_.setOption("live_variables",true);
rfcn_.init();
if(verbose_){
cout << "Generated residual function ( " << shared_cast<SXFunction>(rfcn_).getAlgorithmSize() << " nodes)." << endl;
}
// Difference vector d
SX d = ssym("d",nv);
if(!gauss_newton_){
vector<SX> dg = ssym("dg",nv).data();
开发者ID:BrechtBa,项目名称:casadi,代码行数:67,代码来源:lifted_sqp_internal.cpp
示例14: motif4generate
//.........这里部分代码省略.........
MATRIX_T* M = log_ord_index(M4, ind, M4_cols);
VECTOR_ID(free)(M4_cols);
for (int i = 0; i < (int)M->size1; i++) {
VECTOR_ID(view) M_row_i = MATRIX_ID(row)(M, i);
VECTOR_ID(mul)(&M_row_i.vector, w);
}
// id=ID4(ind);
VECTOR_T* id = logical_index(ID4, ind);
VECTOR_ID(add_constant)(id, -1.0);
// l=N4(ind);
VECTOR_T* l = logical_index(N4, ind);
// x=sum(M,2)./l;
VECTOR_T* x = sum(M, 2);
VECTOR_ID(div)(x, l);
// M(M==0)=1;
MATRIX_T* M_eq_0 = compare_elements(M, fp_equal, 0.0);
logical_index_assign(M, M_eq_0, 1.0);
MATRIX_ID(free)(M_eq_0);
// i=prod(M,2).^(1./l);
VECTOR_T* prod_M = prod(M, 2);
MATRIX_ID(free)(M);
VECTOR_T* l_pow_neg_1 = pow_elements(l, -1.0);
VECTOR_ID(free)(l);
VECTOR_T* i = pow_elements(prod_M, l_pow_neg_1);
VECTOR_ID(free)(prod_M);
VECTOR_ID(free)(l_pow_neg_1);
// q = i./x;
VECTOR_T* q = copy(i);
VECTOR_ID(div)(q, x);
VECTOR_ID(free)(x);
// [idu j]=unique(id);
VECTOR_T* j;
VECTOR_T* idu = unique(id, "last", &j);
VECTOR_ID(free)(id);
// j=[0;j];
VECTOR_T* temp = VECTOR_ID(alloc)(j->size + 1);
VECTOR_ID(set)(temp, 0, -1.0);
VECTOR_ID(view) temp_subv = VECTOR_ID(subvector)(temp, 1, j->size);
VECTOR_ID(memcpy)(&temp_subv.vector, j);
VECTOR_ID(free)(j);
j = temp;
// mu=length(idu);
int mu = length(idu);
// i2=zeros(mu,1);
VECTOR_T* i2 = zeros_vector(mu);
// q2=i2; f2=i2;
VECTOR_T* q2 = copy(i2);
VECTOR_T* f2 = copy(i2);
// for h=1:mu
for (int h = 0; h < mu; h++) {
// i2(h)=sum(i(j(h)+1:j(h+1)));
int j_h = (int)VECTOR_ID(get)(j, h);
int j_h_add_1 = (int)VECTOR_ID(get)(j, h + 1);
开发者ID:igormis,项目名称:bct-cpp,代码行数:67,代码来源:motif4funct_wei.cpp
示例15: StringTrim
std::string StringTrim(const std::string& str)
{
std::string copy(str);
StringTrimInPlace(copy);
return copy;
}
开发者ID:BrainDamage,项目名称:spring,代码行数:6,代码来源:Util.cpp
示例16: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
_has_unsaved_data(true),
_current_file(""),
_can_run(false),
_is_running(false),
_is_debug_input(false)
{
ui->setupUi(this);
initStyles();
updateWindowTitle();
redoAvailable(false);
undoAvailable(false);
copyAvailable(false);
_window = this;
ui->debugRun->setVisible(false);
ui->runWidget->setVisible(false);
registerFileType(tr("Yad.Markov.File"),
tr("Markov Algorithm File"),
".yad",
1);
updateDebugMenu();
//Connect MainWindow menu
connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close()));
connect(ui->actionUndo, SIGNAL(triggered()), this, SIGNAL(undo()));
connect(ui->actionRedo, SIGNAL(triggered()), this, SIGNAL(redo()));
connect(ui->actionSelect_All, SIGNAL(triggered()), this, SIGNAL(selectAll()));
connect(ui->actionCopy, SIGNAL(triggered()), this, SIGNAL(copy()));
connect(ui->actionPaste, SIGNAL(triggered()), this, SIGNAL(paste()));
connect(ui->actionCut, SIGNAL(triggered()), this, SIGNAL(cut()));
connect(ui->actionDelete, SIGNAL(triggered()), this, SIGNAL(deleteSelection()));
connect(ui->actionNew, SIGNAL(triggered()), this, SIGNAL(newFile()));
connect(ui->actionOpen, SIGNAL(triggered()), this, SIGNAL(open()));
connect(ui->actionSave, SIGNAL(triggered()), this, SIGNAL(save()));
connect(ui->actionSave_As, SIGNAL(triggered()), this, SIGNAL(saveAs()));
connect(ui->actionTutorial, SIGNAL(triggered()), this, SLOT(tutorial()));
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
//Connect InputWidget and HistoryManager
HistoryManager* history_manager = HistoryManager::getInstance();
connect(ui->input, SIGNAL(addToHistory(QString)),
history_manager, SLOT(addToHistory(QString)));
connect(history_manager, SIGNAL(wordSelected(QString)),
ui->input, SLOT(setInput(QString)));
//Connect HistoryWidget and HistoryManager
connect(ui->history, SIGNAL(inputWordSelected(QString)),
history_manager, SIGNAL(wordSelected(QString)));
connect(ui->history, SIGNAL(removeFromHistory(QString)),
history_manager, SLOT(removeFromHistory(QString)));
connect(history_manager, SIGNAL(historyChanged(QVector<QString>)),
ui->history, SLOT(historyChanged(QVector<QString>)));
//Connect MainWindows and FileManager
FileManager* file_manager = FileManager::getInstance();
connect(this, SIGNAL(newFile()), file_manager, SLOT(newFile()));
connect(this, SIGNAL(open()), file_manager, SLOT(open()));
connect(this, SIGNAL(save()), file_manager, SLOT(save()));
connect(this, SIGNAL(saveAs()), file_manager, SLOT(saveAs()));
connect(file_manager, SIGNAL(hasUnsavedData(bool)),
this, SLOT(hasUnsavedData(bool)));
connect(file_manager, SIGNAL(fileNameChanged(QString)),
this, SLOT(fileNameChanged(QString)));
//Connect MainWindows and EditorWindowWidget
connect(this, SIGNAL(undo()), ui->editorWindow, SLOT(undo()));
connect(this, SIGNAL(redo()), ui->editorWindow, SLOT(redo()));
connect(this, SIGNAL(selectAll()), ui->editorWindow, SLOT(selectAll()));
connect(this, SIGNAL(copy()), ui->editorWindow, SLOT(copy()));
connect(this, SIGNAL(paste()), ui->editorWindow, SLOT(paste()));
connect(this, SIGNAL(cut()), ui->editorWindow, SLOT(cut()));
connect(this, SIGNAL(deleteSelection()),
ui->editorWindow, SLOT(deleteSelection()));
connect(ui->editorWindow, SIGNAL(redoAvailable(bool)),
this, SLOT(redoAvailable(bool)));
connect(ui->editorWindow, SIGNAL(undoAvailable(bool)),
this, SLOT(undoAvailable(bool)));
connect(ui->editorWindow, SIGNAL(copyAvailable(bool)),
this, SLOT(copyAvailable(bool)));
//Connect InputWidget and MarkovRunManager
MarkovRunManager* run_manager = MarkovRunManager::getInstance();
connect(ui->input, SIGNAL(run(QString)),
run_manager, SLOT(runWithoutDebug(QString)));
connect(ui->input, SIGNAL(runWithDebug(QString)),
run_manager, SLOT(runWithDebug(QString)));
connect(run_manager, SIGNAL(runWithoutDebugStarted(QString)),
ui->input, SLOT(runStarted()));
//.........这里部分代码省略.........
开发者ID:Smosia,项目名称:YAD-Studio-mac,代码行数:101,代码来源:MainWindow.cpp
示例17: CSettingString
CSettingPath::CSettingPath(const std::string &id, const CSettingPath &setting)
: CSettingString(id, setting)
{
copy(setting);
}
开发者ID:FLyrfors,项目名称:xbmc,代码行数:5,代码来源:SettingPath.cpp
示例18: copy
RandomListNode *copyRandomList(RandomListNode *head) {
// Note: The Solution object is instantiated only once and is reused by each test case.
map<RandomListNode *,RandomListNode *> index;
return copy(head,index);
}
开发者ID:Sayericplz,项目名称:myleetcode,代码行数:5,代码来源:copyRandomList.cpp
示例19: main
//.........这里部分代码省略.........
}
argc -= optind;
argv += optind;
if (argc < 2)
usage();
if (Rflag && rflag)
errx(1, "the -R and -r options may not be specified together");
if (rflag)
Rflag = 1;
if (Rflag) {
if (Hflag)
fts_options |= FTS_COMFOLLOW;
if (Lflag) {
fts_options &= ~FTS_PHYSICAL;
fts_options |= FTS_LOGICAL;
}
} else {
fts_options &= ~FTS_PHYSICAL;
fts_options |= FTS_LOGICAL | FTS_COMFOLLOW;
}
(void)signal(SIGINFO, siginfo);
/* Save the target base in "to". */
target = argv[--argc];
if (strlcpy(to.p_path, target, sizeof(to.p_path)) >= sizeof(to.p_path))
errx(1, "%s: name too long", target);
to.p_end = to.p_path + strlen(to.p_path);
if (to.p_path == to.p_end) {
*to.p_end++ = '.';
*to.p_end = 0;
}
have_trailing_slash = (to.p_end[-1] == '/');
if (have_trailing_slash)
STRIP_TRAILING_SLASH(to);
to.target_end = to.p_end;
/* Set end of argument list for fts(3). */
argv[argc] = NULL;
/*
* Cp has two distinct cases:
*
* cp [-R] source target
* cp [-R] source1 ... sourceN directory
*
* In both cases, source can be either a file or a directory.
*
* In (1), the target becomes a copy of the source. That is, if the
* source is a file, the target will be a file, and likewise for
* directories.
*
* In (2), the real target is not directory, but "directory/source".
*/
r = stat(to.p_path, &to_stat);
if (r == -1 && errno != ENOENT)
err(1, "%s", to.p_path);
if (r == -1 || !S_ISDIR(to_stat.st_mode)) {
/*
* Case (1). Target is not a directory.
*/
if (argc > 1)
errx(1, "%s is not a directory", to.p_path);
/*
* Need to detect the case:
* cp -R dir foo
* Where dir is a directory and foo does not exist, where
* we want pathname concatenations turned on but not for
* the initial mkdir().
*/
if (r == -1) {
if (Rflag && (Lflag || Hflag))
stat(*argv, &tmp_stat);
else
lstat(*argv, &tmp_stat);
if (S_ISDIR(tmp_stat.st_mode) && Rflag)
type = DIR_TO_DNE;
else
type = FILE_TO_FILE;
} else
type = FILE_TO_FILE;
if (have_trailing_slash && type == FILE_TO_FILE) {
if (r == -1)
errx(1, "directory %s does not exist",
to.p_path);
else
errx(1, "%s is not a directory", to.p_path);
}
} else
/*
* Case (2). Target is a directory.
*/
type = FILE_TO_DIR;
exit (copy(argv, type, fts_options));
}
开发者ID:2014-class,项目名称:freerouter,代码行数:101,代码来源:cp.c
示例20: GetNode
/* Initialize the robot's actuator and sensor objects. */
motorActuator = GetActuator<CCI_DSA>("differential_steering");
compass = GetSensor<CCI_PS> ("positioning");
proximitySensor = GetSensor<CCI_FBPS> ("footbot_proximity");
TConfigurationNode DSA_params = GetNode(node, "DSA_params");
GetNodeAttribute(DSA_params, "RobotForwardSpeed", RobotForwardSpeed);
GetNodeAttribute(DSA_params, "RobotTurningSpeed", RobotTurningSpeed);
GetNodeAttribute(DSA_params, "AngleToleranceInDegrees", angleInDegrees);
GetNodeAttribute(DSA_params, "NumberOfRobots", NumberOfRobots);
GetNodeAttribute(DSA_params, "NumberOfSpirals", NumberOfSpirals);
AngleToleranceInRadians.Set(-ToRadians(angleInDegrees),ToRadians(angleInDegrees));
stepSize = 0.1; /* Assigns the robot's stepSize */
startPosition = CVector3(0.0, 0.0, 0.0);
RNG = CRandom::CreateRNG("argos");
generatePattern(NumberOfSpirals, NumberOfRobots);
}
bool DSA_controller::Stop()
{
bool stop = false;
if(stopTimeStep > 0)
{
stopTimeStep--;
stop = true;
}
return stop;
}
void DSA_controller::SetStop(size_t stop_time_in_seconds)
{
stopTimeStep += stop_time_in_seconds * loopFunctions.TicksPerSecond;
}
void DSA_controller::GetPattern(string ith_Pattern)
{
copy(ith_Pattern.begin(),ith_Pattern.end(),back_inserter(tempPattern));
reverse(tempPattern.begin(), tempPattern.end());
}
// /*****
// *
// *****/
void DSA_controller::CopyPatterntoTemp()
{
copy(pattern.begin(),pattern.end(),back_inserter(tempPattern));
reverse(tempPattern.begin(),tempPattern.end());/* Reverses the tempPattern */
}
开发者ID:gmfricke,项目名称:iAnt-ARGoS,代码行数:55,代码来源:DSA_controller.cpp
注:本文中的copy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论