本文整理汇总了C++中DataElement::getData方法的典型用法代码示例。如果您正苦于以下问题:C++ DataElement::getData方法的具体用法?C++ DataElement::getData怎么用?C++ DataElement::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataElement
的用法示例。
在下文中一共展示了DataElement::getData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
int Hash_Map_Example::run (void)
{
ACE_TRACE ("Hash_Map_Example::run");
for (int i = 0; i < 100; i++)
{
map_.bind (i, DataElement (i));
}
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Map has\n")));
for (int j = 0; j < 100; j++)
{
DataElement d;
map_.find (j, d);
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%d:"), d.getData ()));
}
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
// Use the forward iterator.
this->iterate_forward ();
// Use the reverse iterator.
this->iterate_reverse ();
// Remove all the elements from the map.
this->remove_all ();
// Iterate through the map again.
this->iterate_forward ();
return 0;
}
示例2: runStackUnboundedQueue
// Listing 1 code/ch05
int QueueExample::runStackUnboundedQueue (void)
{
ACE_TRACE ("QueueExample::runStackUnboundedQueue");
ACE_Unbounded_Queue<DataElement> queue;
DataElement elem1[10];
int i;
for (i = 0; i < 10; i++)
{
elem1[i].setData (9-i);
queue.enqueue_head (elem1[i]);
}
DataElement elem2[10];
for (i = 0; i < 10; i++)
{
elem2[i].setData (i+10);
queue.enqueue_tail (elem2[i]);
}
for (ACE_Unbounded_Queue_Iterator<DataElement> iter (queue);
!iter.done ();
iter.advance ())
{
DataElement *elem = 0;
iter.next (elem);
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%d:"), elem->getData ()));
}
return 0;
}
示例3: runBoundedStack
// Listing 1 code/ch05
int StackExample::runBoundedStack (void)
{
ACE_TRACE (ACE_TEXT ("StackExample::runBoundedStack"));
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Using a bounded stack\n")));
ACE_Bounded_Stack<DataElement> bstack1 (100);
// The element array is constrained to this scope.
{
DataElement elem[100];
for (int i = 0; i < 100; i++)
{
elem[i].setData(i);
// Push the element on the stack.
bstack1.push (elem[i]);
}
}
ACE_Bounded_Stack<DataElement> bstack2 (100);
// Make a copy!
bstack2 = bstack1;
for (int j = 0; j < 100; j++)
{
DataElement elem;
bstack2.pop (elem);
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%d:"), elem.getData ()));
}
return 0;
}
示例4: runUnboundedSet
// Listing 1
// Listing 2 code/ch05
int SetExample::runUnboundedSet ()
{
ACE_TRACE (ACE_TEXT ("SetExample::runUnboundedSet"));
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Using an unbounded set.\n")));
ACE_Unbounded_Set<DataElement*> uset;
for (int m = 0; m < 100; m++)
{
DataElement *elem;
ACE_NEW_RETURN (elem, DataElement (m), -1);
uset.insert (elem);
}
DataElement deBegin (0), deEnd (99);
if (!uset.find (&deBegin) && !uset.find (&deEnd))
{
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Found the elements\n")));
}
// Iterate and destroy the elements in the set.
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Deleting the elements\n")));
ACE_Unbounded_Set_Iterator<DataElement*> iter (uset);
for (iter = uset.begin (); iter != uset.end (); iter++)
{
DataElement* elem = (*iter);
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%d:"), elem->getData ()));
delete elem;
}
return 0;
}
示例5: run
int Tree_Example::run ()
{
ACE_TRACE (ACE_TEXT ("Tree_Example::run"));
DataElement *d = 0;
for (int i = 0; i < 100; i++)
{
ACE_NEW_RETURN (d, DataElement (i), -1);
int result = tree_.bind(i, d);
if (result != 0)
{
ACE_ERROR_RETURN((LM_ERROR, "%p\n", "Bind"), -1);
}
}
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Using find: \n")));
for (int j = 0; j < 100; j++)
{
DataElement* d;
int result = tree_.find (j, d);
if (result != 0)
{
ACE_ERROR_RETURN((LM_ERROR, "%p\n", "Find"), -1);
}
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%d:"), d->getData ()));
}
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
// Use the forward iterator.
this->iterate_forward ();
// Use the reverse iterator.
this->iterate_reverse ();
// Remove all elements from the tree.
ACE_ASSERT (this->remove_all ()!= -1);
// Iterate through once again.
this->iterate_forward ();
return 0;
}
示例6: runFixedStack
// Listing 1
// Listing 2 code/ch05
int StackExample::runFixedStack (void)
{
ACE_TRACE (ACE_TEXT ("StackExample::runFixedStack"));
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Using a fixed stack\n")));
ACE_Fixed_Stack<DataElement*, 100> fstack;
for (int k = 0; k < 100; k++)
{
DataElement* elem;
ACE_NEW_RETURN(elem, DataElement (k), -1);
fstack.push (elem); // Push the element on the stack.
}
for (int l = 0; l < 100; l++)
{
DataElement* elem = 0;
fstack.pop (elem);
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%d:"), elem->getData ()));
delete elem;
}
return 0;
}
示例7: run
int Map_Example::run (void)
{
ACE_TRACE (ACE_TEXT ("Map_Example::run"));
// Corresponding KeyType objects are created on the fly.
for (int i = 0; i < 100; i++)
{
map_.bind (i, DataElement (i));
}
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Map has\n")));
for (int j = 0; j < 100; j++)
{
DataElement d;
int result = map_.find (j,d);
if (result == 0)
{
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%d:"), d.getData ()));
}
}
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
// Iterate in the forward direction.
this->iterate_forward ();
// Iterate in the other direction.
this->iterate_reverse ();
// Remove all elements from the map.
this->remove_all ();
// Iterate in the forward direction.
this->iterate_forward ();
return 0;
}