本文整理汇总了C++中SimpleList类的典型用法代码示例。如果您正苦于以下问题:C++ SimpleList类的具体用法?C++ SimpleList怎么用?C++ SimpleList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_simple_list
void test_simple_list()
{
SimpleList<int> slist;
for (int i = 0; i < 10; ++i) {
slist.push_back(i);
}
}
示例2: main
int main()
{
SimpleList l;
char c;
printf("testing insert/remove...");
if (!l.insert(-1, 'a'))
goto fail;
if (!l.insert(-1, 'b'))
goto fail;
if (!l.insert(1, 'c'))
goto fail;
if (!l.remove(0, &c) || c != 'a')
goto fail;
if (!l.remove(1, &c) || c != 'b')
goto fail;
if (!l.remove(0, &c) || c != 'c')
goto fail;
printf("[ok]\n");
printf("testing count...");
if (l.get_count() != 0)
goto fail;
l.insert(-1, 'a');
if (l.get_count() != 1)
goto fail;
printf("[ok]\n");
return 0;
fail:
printf("[failed]\n");
return -1;
}
示例3: copyFloatCategory
void GenericQuery::
copyFloatCategory (SimpleList<float> &to, SimpleList<float> &from)
{
float item;
clearFloatCategory (to);
while (from.Next (item))
to.Append (item);
}
示例4: copyIntegerCategory
void GenericQuery::
copyIntegerCategory (SimpleList<int> &to, SimpleList<int> &from)
{
int item;
clearIntegerCategory (to);
while (from.Next (item))
to.Append (item);
}
示例5: clearFloatCategory
void GenericQuery::
clearFloatCategory (SimpleList<float> &float_category)
{
float item;
float_category.Rewind ();
while (float_category.Next (item))
float_category.DeleteCurrent ();
}
示例6: clearIntegerCategory
void GenericQuery::
clearIntegerCategory (SimpleList<int> &int_category)
{
int item;
int_category.Rewind ();
while (int_category.Next (item))
int_category.DeleteCurrent ();
}
示例7: simpleListSetFirst_base
void simpleListSetFirst_base(SimpleList l, const Ptr data) {
if(l->delFct)
l->delFct((void *)l->first+sizeof(struct _SimpleListNode));
if(l->copyFct)
l->copyFct((void *)l->first+sizeof(struct _SimpleListNode), data);
else
memcpy((void *)l->first+sizeof(struct _SimpleListNode), data, l->elemSize);
}
示例8: getPlugins
void
CollectorPluginManager::Shutdown()
{
CollectorPlugin *plugin;
SimpleList<CollectorPlugin *> plugins = getPlugins();
plugins.Rewind();
while (plugins.Next(plugin)) {
plugin->shutdown();
}
}
示例9: getPlugins
void
NegotiatorPluginManager::Update(const ClassAd &ad)
{
NegotiatorPlugin *plugin;
SimpleList<NegotiatorPlugin *> plugins = getPlugins();
plugins.Rewind();
while (plugins.Next(plugin)) {
plugin->update(ad);
}
}
示例10: testSet
void AbstractSequentialListTest::testSet() {
SimpleList<int> list;
try {
list.set( 0, 12 );
CPPUNIT_FAIL("should throw IndexOutOfBoundsException");
} catch( IndexOutOfBoundsException& e ) {
// expected
}
}
示例11: testAddAll
void AbstractSequentialListTest::testAddAll() {
LinkedList<int> collection;
for( int i = 0; i < 50; ++i ) {
collection.add( i );
}
SimpleList<int> list;
list.addAll( collection );
CPPUNIT_ASSERT_MESSAGE( "Should return true", list.addAll( 2, collection ) );
}
示例12: testIterator
void AbstractListTest::testIterator() {
SimpleList<int> list;
list.add( 10 );
list.add( 20 );
std::auto_ptr< Iterator<int> > iter( list.iterator() );
CPPUNIT_ASSERT_EQUAL( 10, iter->next() );
iter->remove();
CPPUNIT_ASSERT_EQUAL( 20, iter->next() );
}
示例13: testIndexOf
void AbstractListTest::testIndexOf() {
SimpleList<int> array;
for( int i = 1; i < 6; i++ ) {
array.add(i);
}
MockArrayList<int> list;
list.addAll( array );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "find 0 in the list do not contain 0", -1, list.indexOf( 0 ) );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "did not return the right location of element 3", 2, list.indexOf( 3 ) );
}
示例14: testRemove
void AbstractSequentialListTest::testRemove() {
SimpleList<int> list;
list.add(1);
CPPUNIT_ASSERT_EQUAL( 1, list.removeAt( 0 ) );
list.add( 2 );
CPPUNIT_ASSERT_EQUAL( 2, list.removeAt( 0 ) );
// remove index is out of bounds
try {
list.removeAt( list.size() );
CPPUNIT_FAIL("Should throw IndexOutOfBoundsException.");
} catch( IndexOutOfBoundsException& e ) {
// expected
}
try {
list.removeAt( -1 );
CPPUNIT_FAIL("Should throw IndexOutOfBoundsException.");
} catch( IndexOutOfBoundsException& e ) {
// expected
}
// list dont't support remove operation
try {
MockAbstractSequentialList<int> mylist;
mylist.removeAt( 0 );
CPPUNIT_FAIL("Should throw UnsupportedOperationException.");
} catch( UnsupportedOperationException& e ) {
// expected
}
}
示例15: GetListPeerId
int TcpClient::GetListPeerId(SimpleList<unsigned int>& listId)
{
unsigned int pid = MsgSocket::GetPeerPid();
if(pid != 0)
{
listId.Add(pid);
return 1;
}
return 0;
}