本文整理汇总了C++中set2函数的典型用法代码示例。如果您正苦于以下问题:C++ set2函数的具体用法?C++ set2怎么用?C++ set2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set2函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: partition
/*
** Does the partition: Pivot P is at the top of the stack.
** precondition: a[lo] <= P == a[up-1] <= a[up],
** so it only needs to do the partition from lo + 1 to up - 2.
** Pos-condition: a[lo .. i - 1] <= a[i] == P <= a[i + 1 .. up]
** returns 'i'.
*/
static IdxT partition (lua_State *L, IdxT lo, IdxT up) {
IdxT i = lo; /* will be incremented before first use */
IdxT j = up - 1; /* will be decremented before first use */
/* loop invariant: a[lo .. i] <= P <= a[j .. up] */
for (;;) {
/* next loop: repeat ++i while a[i] < P */
while (lua_geti(L, 1, ++i), sort_comp(L, -1, -2)) {
if (i == up - 1) /* a[i] < P but a[up - 1] == P ?? */
luaL_error(L, "invalid order function for sorting");
lua_pop(L, 1); /* remove a[i] */
}
/* after the loop, a[i] >= P and a[lo .. i - 1] < P */
/* next loop: repeat --j while P < a[j] */
while (lua_geti(L, 1, --j), sort_comp(L, -3, -1)) {
if (j < i) /* j < i but a[j] > P ?? */
luaL_error(L, "invalid order function for sorting");
lua_pop(L, 1); /* remove a[j] */
}
/* after the loop, a[j] <= P and a[j + 1 .. up] >= P */
if (j < i) { /* no elements out of place? */
/* a[lo .. i - 1] <= P <= a[j + 1 .. i .. up] */
lua_pop(L, 1); /* pop a[j] */
/* swap pivot (a[up - 1]) with a[i] to satisfy pos-condition */
set2(L, up - 1, i);
return i;
}
/* otherwise, swap a[i] - a[j] to restore invariant and repeat */
set2(L, i, j);
}
}
开发者ID:guodawei,项目名称:lua,代码行数:37,代码来源:ltablib.c
示例2: addRecursive
bool addRecursive(CuckooMap* map, uint64_t key, uint64_t value, int depth)
{
if(depth > MAX_LOOP)
{
return false;
}
//if its empty in the first table, add it there
if(getKey1(map, key) == NONE)
{
set1(map, key, value);
}
//if its empty in the second table, add it there
else if(getKey2(map, key) == NONE)
{
set2(map, key, value);
}
//if both are occupied, randomly displace one and re-add the displaced one
else if((xorshf96() & 1) == 0)
{
uint64_t pushedKey = getKey1(map, key);
uint64_t pushedValue = getValue1(map, key);
set1(map, key, value);
return addRecursive(map, pushedKey, pushedValue, depth + 1);
}
else
{
uint64_t pushedKey = getKey2(map, key);
uint64_t pushedValue = getValue2(map, key);
set2(map, key, value);
return addRecursive(map, pushedKey, pushedValue, depth + 1);
}
return true;
}
开发者ID:seokhohong,项目名称:Reverse-Game-Of-Life,代码行数:33,代码来源:CuckooMap.c
示例3: auxsort
/*
** QuickSort algorithm (recursive function)
*/
static void auxsort (lua_State *L, IdxT lo, IdxT up,
unsigned int rnd) {
while (lo < up) { /* loop for tail recursion */
IdxT p; /* Pivot index */
IdxT n; /* to be used later */
/* sort elements 'lo', 'p', and 'up' */
lua_geti(L, 1, lo);
lua_geti(L, 1, up);
if (sort_comp(L, -1, -2)) /* a[up] < a[lo]? */
set2(L, lo, up); /* swap a[lo] - a[up] */
else
lua_pop(L, 2); /* remove both values */
if (up - lo == 1) /* only 2 elements? */
return; /* already sorted */
if (up - lo < RANLIMIT || rnd == 0) /* small interval or no randomize? */
p = (lo + up)/2; /* middle element is a good pivot */
else /* for larger intervals, it is worth a random pivot */
p = choosePivot(lo, up, rnd);
lua_geti(L, 1, p);
lua_geti(L, 1, lo);
if (sort_comp(L, -2, -1)) /* a[p] < a[lo]? */
set2(L, p, lo); /* swap a[p] - a[lo] */
else {
lua_pop(L, 1); /* remove a[lo] */
lua_geti(L, 1, up);
if (sort_comp(L, -1, -2)) /* a[up] < a[p]? */
set2(L, p, up); /* swap a[up] - a[p] */
else
lua_pop(L, 2);
}
if (up - lo == 2) /* only 3 elements? */
return; /* already sorted */
lua_geti(L, 1, p); /* get middle element (Pivot) */
lua_pushvalue(L, -1); /* push Pivot */
lua_geti(L, 1, up - 1); /* push a[up - 1] */
set2(L, p, up - 1); /* swap Pivot (a[p]) with a[up - 1] */
p = partition(L, lo, up);
/* a[lo .. p - 1] <= a[p] == P <= a[p + 1 .. up] */
if (p - lo < up - p) { /* lower interval is smaller? */
auxsort(L, lo, p - 1, rnd); /* call recursively for lower interval */
n = p - lo; /* size of smaller interval */
lo = p + 1; /* tail call for [p + 1 .. up] (upper interval) */
}
else {
auxsort(L, p + 1, up, rnd); /* call recursively for upper interval */
n = up - p; /* size of smaller interval */
up = p - 1; /* tail call for [lo .. p - 1] (lower interval) */
}
if ((up - lo) / 128 > n) /* partition too imbalanced? */
rnd = l_randomizePivot(); /* try a new randomization */
} /* tail call auxsort(L, lo, up, rnd) */
}
开发者ID:guodawei,项目名称:lua,代码行数:55,代码来源:ltablib.c
示例4: s
TSet TSet::operator-(const int Elem) // разность с элементом
{
TBitField s(MaxPower);
s.SetBit(Elem);
TSet set2(BitField & s);
return set2;
}
开发者ID:DariaPanenkova,项目名称:mp2-lab1-set,代码行数:7,代码来源:tset.cpp
示例5: TEST
TEST(TSet, compare_two_sets_of_non_equal_sizes)
{
const int size1 = 4, size2 = 6;
TSet set1(size1), set2(size2);
EXPECT_EQ(1, set1 != set2);
}
开发者ID:NorthlaneKek,项目名称:mp2-lab1-set,代码行数:7,代码来源:test_tset.cpp
示例6: TEST
TEST(IntervalTest, IntersectionTest)
{
Interval<int> interval((Bound<int>::open(4), Bound<int>::closed(6)));
Interval<int> interval2((Bound<int>::closed(1), Bound<int>::closed(5)));
Interval<int> interval3((Bound<int>::closed(7), Bound<int>::closed(8)));
IntervalSet<int> set((Bound<int>::closed(1), Bound<int>::closed(3)));
IntervalSet<int> set2((Bound<int>::open(2), Bound<int>::open(4)));
IntervalSet<int> set3((Bound<int>::open(6), Bound<int>::closed(7)));
EXPECT_FALSE(set.intersects(interval));
EXPECT_TRUE(set2.intersects(interval2));
EXPECT_TRUE(set3.intersects(interval3));
EXPECT_FALSE(set2.intersects(interval));
EXPECT_TRUE(set2.intersects(interval2));
EXPECT_FALSE(set2.intersects(interval3));
EXPECT_TRUE(set.intersects(set2));
EXPECT_TRUE(set2.intersects(set));
EXPECT_FALSE(set3.intersects(set2));
EXPECT_TRUE(interval.intersects(interval2));
EXPECT_FALSE(interval2.intersects(interval3));
EXPECT_FALSE(interval3.intersects(interval));
}
开发者ID:447327642,项目名称:mesos,代码行数:26,代码来源:interval_tests.cpp
示例7: main
int main(int argc, char *argv[])
{
/* sets to be used for testing */
char s[5] = {'1','2','3','4','\0'};
char t[4] = {'1','2','3','\0'};
char u[1] = {'\0'};
char v[4] = {'x','y','z','\0'};
/* sets to contain results */
char a[SIZE];
char b[SIZE];
char c[SIZE];
char d[SIZE];
/* SetTypes for testing */
SetType set1(s);
SetType set2(t);
SetType set3(u);
/* test of is_empty. Should output "Set is empty" followed by "Set is not
empty */
set3.is_empty() ? cout << "Set is empty\n" : cout << "Set is not empty\n";
set1.is_empty() ? cout << "Set is empty\n" : cout << "Set is not empty\n";
/* test of is_equal. Should output "s is equal" followed by "t is not equal"
*/
set1.is_equal(s) ? cout << "s is equal\n" : cout << "s is not equal\n";
set1.is_equal(t) ? cout << "t is equal\n" : cout << "t is not equal\n";
/* test of is_member. Should output "4 is a member" followed by "8 is not a
member */
set1.is_member('4') ? cout << "4 is a member\n" : cout << "4 is not a member\n";
set1.is_member('8') ? cout << "8 is a member\n" : cout << "8 is not a member\n";
/* test of is_subset. Should output "t is a subset" followed by "v is not a
subset */
set1.is_subset(t) ? cout << "t is a subset\n" : cout << "t is not a subset\n";
set1.is_subset(v) ? cout << "v is a subset\n" : cout << "v is not a subset\n";
/* test of setunion. Should output all elements from s and v. Implicitly
tests the write function. */
set1.setunion(v, a);
SetType set4(a);
set4.write();
/* test of intersection. Should output all elements in both t and s. */
set1.intersection(t, b);
SetType set5(b);
set5.write();
/* test of difference. Should output all elements only in t or only in s */
set1.difference(t, d);
SetType set7(d);
set7.write();
/* return success */
return 0;
}
开发者ID:BSierakowski,项目名称:personal_code,代码行数:58,代码来源:main.cpp
示例8: set1
void parser_imp::code_with_callbacks(std::function<void()> && f) {
m_script_state->apply([&](lua_State * L) {
set_io_state set1(L, m_io_state);
set_environment set2(L, m_env);
m_script_state->exec_unprotected([&]() {
f();
});
});
}
开发者ID:Paradoxika,项目名称:lean,代码行数:9,代码来源:parser_imp.cpp
示例9: t_reverse
static int t_reverse (lua_State *L) {
int u = aux_getn(L, 1);
int l = 1;
while (l < u) {
get2(L, l, u);
set2(L, l, u);
++l; --u;
}
return 0;
}
开发者ID:whoopdedo,项目名称:lgscript,代码行数:10,代码来源:lext.c
示例10: set2
DWORD U16Parser::Serialize(BYTE* data,DWORD size)
{
if (size<2)
return -1;
//Serialize
set2(data,0,value);
return 2;
}
开发者ID:chenxiuheng,项目名称:mcumediaserver,代码行数:10,代码来源:amf3.cpp
示例11: SqlStatement
SqlInsert::operator SqlStatement() const {
String s = "insert into " + table.Quoted();
if(!set1.IsEmpty()) {
s << set1();
if(sel.IsValid())
s << ' ' << SqlStatement(sel).GetText();
else if(!set2.IsEmpty())
s << " values " << set2();
}
return SqlStatement(s);
}
开发者ID:guowei8412,项目名称:upp-mirror,代码行数:11,代码来源:SqlStatement.cpp
示例12: test_copy
static void test_copy(std::vector<T> const& data)
{
sib::vector_set<T> set1;
for(std::size_t ii = 0; ii != data.size(); ++ii)
set1.insert(data[ii]);
sib::vector_set<T> set2(const_cast<sib::vector_set<T> const&>(set1));
EXPECT_EQ(set1.size(), set2.size());
typename sib::vector_set<T>::const_iterator i1 = set1.begin();
typename sib::vector_set<T>::const_iterator i2 = set2.begin();
for(std::size_t ii = 0; ii != data.size(); ++ii)
EXPECT_TRUE(*(i1++) == *(i2++));
}
开发者ID:staticimport,项目名称:sib,代码行数:12,代码来源:vector_set_test.cpp
示例13: AddElem
/*
this function add a new item to svMapRaw.
svMapRaw is from a postfix to a vector of possible predict words.
*/
void AddElem( Flex2WordMap& svMapRaw,
const string &Postfix,
int LemmaInfoNo,
const WORD nps,
const WORD ItemNo,
const DwordVector& ModelFreq,
const vector<CLemmaInfoAndLemma>& LemmaInfos
)
{
// ============= determine the part of speech (nps)
const CLemmaInfo& LemmaInfo = LemmaInfos[LemmaInfoNo].m_LemmaInfo;
// ============= adding to svMapRaw, if not exists, otherwise update frequence
CPredictWord set2(1, LemmaInfoNo, nps, ItemNo);
Flex2WordMap::iterator svMapIt = svMapRaw.find(Postfix);
if( svMapIt==svMapRaw.end() )
{
vector<CPredictWord> set2vec;
set2vec.push_back(set2);
svMapRaw[Postfix] = set2vec;
}
else
{
int i=0;
for( ; i<svMapIt->second.size(); i++ )
{
// if postfix, flexia and PartOfSpeech are equal then we should update frequence and exit
if( svMapIt->second[i].m_nps == set2.m_nps )
{
svMapIt->second[i].m_Freq++;
// if the new example is more frequent then we should predict using this example
const CLemmaInfo& OldLemmaInfo = LemmaInfos[svMapIt->second[i].m_LemmaInfoNo].m_LemmaInfo;
if (ModelFreq[LemmaInfo.m_FlexiaModelNo] > ModelFreq[OldLemmaInfo.m_FlexiaModelNo])
{
svMapIt->second[i].m_LemmaInfoNo = LemmaInfoNo;
svMapIt->second[i].m_ItemNo = ItemNo;
};
break;
}
}
// if no such part of speech for this postfix and flexia is found
// then add new item
if( i>= svMapIt->second.size() )
svMapIt->second.push_back(set2);
}
}
开发者ID:dkrotx,项目名称:gogo_lemmatizer,代码行数:58,代码来源:CreatePredictionBase.cpp
示例14: TEST
TEST(TSet, can_use_sum_for_three_sets)
{
const int size = 10;
TSet set0(size), set1(size), set2(size), set3(size), expSet(size);
set0.InsElem(1);
set1.InsElem(3);
set2.InsElem(5);
set3 = set0 + set1 + set2;
expSet.InsElem(1);
expSet.InsElem(3);
expSet.InsElem(5);
EXPECT_EQ(expSet, set3);
}
开发者ID:Lyzzerg,项目名称:mp2-lab1-set,代码行数:13,代码来源:test_tset.cpp
示例15: set_bufsize
static void *limiter_new(t_symbol *s, int argc, t_atom *argv)
{
t_limiter *x = (t_limiter *)pd_new(limiter_class);
int i = 0;
if (argc) set_bufsize(x, atom_getfloat(argv));
else
{
argc = 1;
set_bufsize(x, 0);
}
if (argc > 64) argc=64;
if (argc == 0) argc=1;
x->number_of_inlets = argc--;
while (argc--)
{
inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
}
outlet_new(&x->x_obj, &s_signal);
x->in = (t_inbuf*)getbytes(sizeof(t_inbuf) * x->number_of_inlets);
while (i < x->number_of_inlets)
{
int n;
t_sample* buf = (t_sample *)getbytes(sizeof(*buf) * x->buf_size);
x->in[i].ringbuf = buf;
x->in[i].buf_position = 0;
for (n = 0; n < x->buf_size; n++) x->in[i].ringbuf[n] = 0.;
i++;
}
x->val1 = (t_limctl *)getbytes(sizeof(t_limctl));
x->val2 = (t_limctl *)getbytes(sizeof(t_limctl));
x->cmp = (t_cmpctl *)getbytes(sizeof(t_cmpctl));
x->cmp->ratio = 1.;
x->cmp->treshold = 1;
set1(x, 100, 30, 139);
set2(x, 110, 5, 14.2);
x->amplification= 1;
x->samples_left = x->still_left = x->mode = 0;
return (x);
}
开发者ID:Tzero2,项目名称:pd,代码行数:50,代码来源:limiter~.c
示例16: QToolBar
Tools_toolbar::Tools_toolbar(CGAL::Qt_widget *w,
QMainWindow *mw) : QToolBar(mw, "NT")
{
w->attach(&input_point);
input_point.deactivate();
w->attach(&input_line);
input_line.deactivate();
w->attach(&input_polygon);
input_polygon.deactivate();
//set the widget
widget = w;
QIconSet set0(QPixmap( (const char**)arrow_small_xpm ),
QPixmap( (const char**)arrow_xpm ));
QIconSet set1(QPixmap( (const char**)point_small_xpm ),
QPixmap( (const char**)point_xpm ));
QIconSet set2(QPixmap( (const char**)line_small_xpm ),
QPixmap( (const char**)line_xpm ));
QIconSet set3(QPixmap( (const char**)polygon_small_xpm ),
QPixmap( (const char**)polygon_xpm ));
but[0] = new QToolButton(this, "Deactivate Layer");
but[0]->setIconSet(set0);
but[0]->setTextLabel("Deactivate Layer");
but[1] = new QToolButton(this, "pointinput layer");
but[1]->setIconSet(set1);
but[1]->setTextLabel("Input Point");
but[2] = new QToolButton(this, "lineinput layer");
but[2]->setIconSet(set2);
but[2]->setTextLabel("Input Line");
but[3] = new QToolButton(this, "polygoninput layer");
but[3]->setIconSet(set3);
but[3]->setTextLabel("Input Simple Polygon");
nr_of_buttons = 4;
button_group = new QButtonGroup(0, "My_group");
for(int i = 0; i<nr_of_buttons; i++) {
button_group->insert(but[i]);
but[i]->setToggleButton(true);
}
button_group->setExclusive(true);
connect(but[1], SIGNAL(stateChanged(int)),
&input_point, SLOT(stateChanged(int)));
connect(but[2], SIGNAL(stateChanged(int)),
&input_line, SLOT(stateChanged(int)));
connect(but[3], SIGNAL(stateChanged(int)),
&input_polygon, SLOT(stateChanged(int)));
}
开发者ID:BijanZarif,项目名称:mshr,代码行数:50,代码来源:Qt_widget_toolbar.cpp
示例17: wxLogError
void dlgSelectConnection::OnChangeServer(wxCommandEvent& ev)
{
if (!GetServer())
return;
cbDatabase->Clear();
int sel=cbServer->GetCurrentSelection();
if (sel >= 0)
{
remoteServer = (pgServer*)cbServer->GetClientData(sel);
if (!remoteServer->GetConnected())
{
remoteServer->Connect(mainForm, remoteServer->GetStorePwd());
if (!remoteServer->GetConnected())
{
wxLogError(wxT("%s"), remoteServer->GetLastError().c_str());
return;
}
}
if (remoteServer->GetConnected())
{
pgSetIterator set1(remoteServer->GetConnection(),
wxT("SELECT DISTINCT datname\n")
wxT(" FROM pg_database db\n")
wxT(" WHERE datallowconn ORDER BY datname"));
while(set1.RowsLeft())
cbDatabase->Append(set1.GetVal(wxT("datname")));
if (cbDatabase->GetCount())
cbDatabase->SetSelection(0);
pgSetIterator set2(remoteServer->GetConnection(),
wxT("SELECT DISTINCT usename\n")
wxT("FROM pg_user db\n")
wxT("ORDER BY usename"));
while(set2.RowsLeft())
cbUsername->Append(set2.GetVal(wxT("usename")));
if (cbUsername->GetCount())
cbUsername->SetSelection(0);
}
}
OnChangeDatabase(ev);
}
开发者ID:xiul,项目名称:Database-Designer-for-pgAdmin,代码行数:49,代码来源:dlgSelectConnection.cpp
示例18: already_copied
Sprite *Thought_Bubble::copy(boolean also_copy_offsets) {
Sprite *copied = already_copied(this); // new on 210203
if (copied != NULL) {
return(copied);
};
Thought_Bubble *copy = new Thought_Bubble(llx,lly,current_priority,width,height); // moved here on 210203 so can deal with circularities better
// just_copied(this,copy); -- moved into top_level_copy on 210203
// some reason this wasn't really centering it appropriately
// reason is that the bb is wrong since it picked up the first little bubble
// city_coordinate center_x, center_y;
// center_location(center_x,center_y);
Cubby *cubby_copy = NULL;
// setting and resetting the following flag is not very elegant
// but since it is an atomic operation there is no problem
// used by numbers to determine if ok to copy blank to blank
// and blank cubbies
//Sprite *saved_tt_top_copy = tt_top_copy; // commented out on 210203 since now uses top_level_copy
//tt_top_copy = NULL; // no sharing inside of thought bubbles
UnwindProtect<boolean> set(tt_copying_entire_thought_bubble,TRUE); // in case a robot is in a thought bubble
UnwindProtect<boolean> set2(tt_dont_connect_things_while_copying,TRUE);
if (cubby != NULL) { // && cubby->pointer_to_leader() == this) { // commented out on 250103
cubby_copy = (Cubby *) (cubby->top_level_copy(TRUE,this,copy)); // made top_level on 100203
};
// Robot *robot_copy = NULL;
// if (robot != NULL) {
// robot_copy = (Robot *) (robot->copy());
// };
// if (cubby_copy != NULL) { // commented out on 250103
//// copy->update_display(); // for the receive_cubby to work right
// copy->receive_cubby(cubby_copy);
// };
// copy->move_to(llx,lly);
// if (saved_width != 0) {
// copy->set_saved_size(saved_width,saved_height);
// };
// tt_copying_entire_thought_bubble = FALSE;
// replaced the above with the following on 201299
// tt_top_copy = saved_tt_top_copy;
// copy->set_priority_fixed(priority_fixed_flag);
if (cubby_copy != NULL) { // condition new on 280103 - thanks Gordon
copy->set_cubby(cubby_copy,FALSE);
copy->add_follower(cubby_copy,TRUE,INSERT_AT_END,TRUE);
cubby_copy->inside_thought_bubble();
};
finish_making_copy(copy,also_copy_offsets);
return(copy);
};
开发者ID:ToonTalk,项目名称:desktop-toontalk,代码行数:47,代码来源:thought.cpp
示例19: main
int main ()
{
RuntimeCmp <int> reverse_order (RuntimeCmp<int>::reverse);
IntSet set1;
IntSet set2 (reverse_order);
set1 = set2;
assert (set1.key_comp () == set2.key_comp ());
assert (set1.value_comp () == set2.value_comp ());
IntMap map1;
IntMap map2 (reverse_order);
map1 = map2;
assert (map1.key_comp () == map2.key_comp ());
return 0;
}
开发者ID:Flameeyes,项目名称:stdcxx,代码行数:17,代码来源:23.associative.stdcxx-16.cpp
注:本文中的set2函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论