本文整理汇总了C++中DLList类的典型用法代码示例。如果您正苦于以下问题:C++ DLList类的具体用法?C++ DLList怎么用?C++ DLList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DLList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ndbrequire
void
Dbtup::fireDetachedTriggers(KeyReqStruct *req_struct,
DLList<TupTriggerData>& triggerList,
Operationrec* const regOperPtr,
bool disk)
{
TriggerPtr trigPtr;
/**
* Set disk page
*/
req_struct->m_disk_page_ptr.i = m_pgman.m_ptr.i;
ndbrequire(regOperPtr->is_first_operation());
triggerList.first(trigPtr);
while (trigPtr.i != RNIL) {
jam();
if ((trigPtr.p->monitorReplicas ||
regOperPtr->op_struct.primary_replica) &&
(trigPtr.p->monitorAllAttributes ||
trigPtr.p->attributeMask.overlaps(req_struct->changeMask))) {
jam();
executeTrigger(req_struct,
trigPtr.p,
regOperPtr,
disk);
}
triggerList.next(trigPtr);
}
}
示例2: main
int main(int argc, char *argv[])
{
DLList<scalar> myList;
for (int i = 0; i<10; i++)
{
myList.append(1.3*i);
}
myList.append(100.3);
myList.append(500.3);
Info<< nl << "And again using STL iterator: " << nl << endl;
forAllIter(DLList<scalar>, myList, iter)
{
Info<< "element:" << *iter << endl;
}
Info<< nl << "And again using the same STL iterator: " << nl << endl;
forAllIter(DLList<scalar>, myList, iter)
{
Info<< "Removing " << myList.remove(iter) << endl;
}
示例3: test1
void test1()
{
DLList list;
list << 1 << 2 << 12 << 13 << 11 << 22;
std::cout<<"List:"<<std::endl;
list.print();
}
示例4: testPart4
void testPart4(BinarySearchTree<BSTNode1<int>, int> *tree) {
cout << "Testing Part 4..." << endl;
cout << "______________________________" << endl;
DLList<int> list = tree->getLE(10);
cout << "All items in tree less than 10: ";
for(int n = 1; n < list.size(); n++){
cout << list.get(n) << ", ";
}
cout << endl;
}
示例5: reverseList
//Method for reversing a list in place.
void reverseList(){
DLList newList;
while (head != NULL)
{
newList.newNodeAtFront(this -> head -> data);
head = head -> next;
}
head = newList.head;
tail = newList.tail;
}
示例6: test4
void test4()
{
DLList list;
list << 1 << 1 << 2 << 3 << 5 << 8 << 13 << 21 << 34 << 55 << 89;
std::cout<<"List:"<<std::endl;
list.print();
std::cout<<std::endl<<"Sorted list:"<<std::endl;
list.printSorted();
std::cout<<std::endl<<"List:"<<std::endl;
list.print();
}
示例7: part4test
bool part4test(){
BinarySearchTree<BSTNode1<int>,int> part4;
part4.add(20);
part4.add(10);
part4.add(30);
part4.add(5);
part4.add(15);
part4.getLE(31);
DLList<int> list = part4.getLE(13);
DLList<int> list2 = part4.getLE(20);
return (list.get(0)==5)&&(list.get(1)==10)&&
(list2.get(0)==5)&&(list2.get(1)==10)&&(list2.get(2)==15)&&(list2.get(3)==20);
}
示例8: test3
void test3()
{
DLList list; int dave;
list << 1 << 1 << 1 << 0 << 0 << 12 << 123123;
std::cout<<"List:"<<std::endl;
list.print();
std::cout<<std::endl<<"Removing last index..."<<std::endl<<std::endl;
std::cout<<"List:"<<std::endl;
bool saved = list.removeLast(dave);
list.print(); std::cout<<std::endl;
std::cout<<"Removed element: "<<dave<<std::endl;
std::cout<<"Success? "<<((saved) ? "Yes." : "No.")<<std::endl;
}
示例9: executeTriggers
void Dbtup::executeTriggers(KeyReqStruct *req_struct,
DLList<TupTriggerData>& triggerList,
Operationrec* regOperPtr,
bool disk)
{
TriggerPtr trigPtr;
triggerList.first(trigPtr);
while (trigPtr.i != RNIL) {
jam();
executeTrigger(req_struct,
trigPtr.p,
regOperPtr,
disk);
triggerList.next(trigPtr);
}
}
示例10: processFile
void processFile (string filename) {
DLList list;
stringstream ss;
ifstream fin(filename.c_str());
if(!fin.fail()) {
string nextline;
while(!fin.eof()) {
getline(fin, nextline);
if(isalpha(nextline[0])) {
list.insert(nextline);
}
else {
list.cycle(atoi(nextline.c_str()));
cout << list.ToString() <<endl << "Won this round" << endl;
cout << list.getDeleted() << endl << "loses this round. " << endl << endl;
}
}
cout <<"Congratulations to: " << list.getFront() << endl << "you won!" << endl;
fin.close();
list.clear();
cout << "INPUT FINISHED" << endl;
}
else {
cout << "Unable to open " << filename << " for processing." << endl;
}
}
示例11: fibNumber
/**********************************************************************
* Fib - setFibNumber
* Inputs: n (int)
* Calculates the n-th Fibonacci number
***********************************************************************/
void Fib::setFibNumber(int n)
{
if (n < 1)
{
cout << "Fibonacci subscript cannot be less than 1\n";
return;
}
/*need to clear fibNumber. setFibNumber() may be called several times on an object and you would have problems if you didn't erase all previous data*/
fibNumber.clear();
fibNumber.insert(1,0); // fibNumber will start as f1. f1 = 1;
fibSubscript = n;
if (n < 3) // can return here if n is 1 or 2.
return;
DLList<int> f2;
f2.insert(1,0); // fibNumber(aka f1) = 1 and f2 = 1. We are rdy to start.
Node<int>* p1;// traversal pointers for DLList objects fibNumber(f1) and f2
Node<int>* p2;
int temp = 0; // used as f1's node value placeholder.
int carry = 0;
for (int i = 0; i < n - 2; i++) //run n - 2 times. f1 and f2 done already
{
//reset pointers to respective beginnings of lists. reset carry to 0
p1 = fibNumber.getFirstNode();
p2 = f2.getFirstNode();
carry = 0;
//Add both lists. fibNumber becomes sum, f2 becomes what fibNumber was
while (p1 != NULL)
{
temp = p1->getData();
p1->setData((p1->getData() + p2->getData() + carry) % 1000000000);
carry = (temp + p2->getData()) / 1000000000;
p2->setData(temp);
p1 = p1->getNext();
p2 = p2->getNext();
}
if (carry == 1) // Account for carry on addition of final nodes.
{
fibNumber.insert(1, fibNumber.getNumItems());
f2.insert(0, f2.getNumItems());
}
}
}
示例12: TestBinarySearchTreeGetLE
void TestBinarySearchTreeGetLE() {
BinarySearchTree<BSTNode1<int>, int> b;
b.add(4);
b.add(2);
b.add(5);
b.add(1);
b.add(3);
b.add(6);
DLList<int> l = b.getLE(3);
assert(l.contains(1));
assert(l.contains(2));
assert(l.contains(3));
assert(!l.contains(4));
assert(!l.contains(5));
assert(!l.contains(6));
}
示例13: findTriggerList
/* ---------------------------------------------------------------- */
Uint32
Dbtup::dropTrigger(Tablerec* table, const DropTrigReq* req, BlockNumber sender)
{
if (ERROR_INSERTED(4004)) {
CLEAR_ERROR_INSERT_VALUE;
return 9999;
}
Uint32 triggerId = req->getTriggerId();
TriggerType::Value ttype = req->getTriggerType();
TriggerActionTime::Value ttime = req->getTriggerActionTime();
TriggerEvent::Value tevent = req->getTriggerEvent();
// ndbout_c("Drop TupTrigger %u = %u %u %u %u by %u", triggerId, table, ttype, ttime, tevent, sender);
DLList<TupTriggerData>* tlist = findTriggerList(table, ttype, ttime, tevent);
ndbrequire(tlist != NULL);
Ptr<TupTriggerData> ptr;
for (tlist->first(ptr); !ptr.isNull(); tlist->next(ptr)) {
jam();
if (ptr.p->triggerId == triggerId) {
if(ttype==TriggerType::SUBSCRIPTION && sender != ptr.p->m_receiverBlock)
{
/**
* You can only drop your own triggers for subscription triggers.
* Trigger IDs are private for each block.
*
* SUMA encodes information in the triggerId
*
* Backup doesn't really care about the Ids though.
*/
jam();
continue;
}
jam();
tlist->release(ptr.i);
return 0;
}
}
return DropTrigRef::TriggerNotFound;
}//Dbtup::dropTrigger()
示例14: while
void
Dbtup::fireDeferredTriggers(Signal* signal,
KeyReqStruct *req_struct,
DLList<TupTriggerData>& triggerList,
Operationrec* const regOperPtr)
{
TriggerPtr trigPtr;
triggerList.first(trigPtr);
while (trigPtr.i != RNIL) {
jam();
if (trigPtr.p->monitorAllAttributes ||
trigPtr.p->attributeMask.overlaps(req_struct->changeMask)) {
jam();
executeTrigger(req_struct,
trigPtr,
regOperPtr);
}//if
triggerList.next(trigPtr);
}//while
}//Dbtup::fireDeferredTriggers()
示例15: test5
void test5()
{
DLList list1, list2;
for (int x = 0; x < 100; ++x) {
if (x % 4 == 0)
list1 << x;
if (x % 5 == 0)
list2 << x;
}
std::cout<<"List1:"<<std::endl;
list1.print(); std::cout<<std::endl;
std::cout<<"List2:"<<std::endl;
list2.print(); std::cout<<std::endl;
std::cout<<"Intersection:"<<std::endl;
DLList * intersect = list1.intersection(list2);
intersect->print(); delete intersect;
}