本文整理汇总了C++中Visitor::Visit方法的典型用法代码示例。如果您正苦于以下问题:C++ Visitor::Visit方法的具体用法?C++ Visitor::Visit怎么用?C++ Visitor::Visit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Visitor
的用法示例。
在下文中一共展示了Visitor::Visit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TopologicalOrderTraversal
//
// This file contains the C++ code from Program 16.9 of
// "Data Structures and Algorithms
// with Object-Oriented Design Patterns in C++"
// by Bruno R. Preiss.
//
// Copyright (c) 1998 by Bruno R. Preiss, P.Eng. All rights reserved.
//
// http://www.pads.uwaterloo.ca/Bruno.Preiss/books/opus4/programs/pgm16_09.cpp
//
void Digraph::TopologicalOrderTraversal (Visitor& visitor) const
{
Array<unsigned int> inDegree (numberOfVertices);
for (Vertex::Number v = 0; v < numberOfVertices; ++v)
inDegree [v] = 0;
Iterator& p = Edges ();
while (!p.IsDone ()) {
Edge& edge = dynamic_cast<Edge&> (*p);
++inDegree [edge.V1 ()];
++p;
}
delete &p;
Queue& queue = *new QueueAsLinkedList ();
queue.RescindOwnership ();
for (Vertex::Number v = 0; v < numberOfVertices; ++v)
if (inDegree [v] == 0)
queue.Enqueue (SelectVertex (v));
while (!queue.IsEmpty () && !visitor.IsDone ())
{
Vertex& vertex =
dynamic_cast<Vertex&> (queue.Dequeue ());
visitor.Visit (vertex);
Iterator& q = EmanatingEdges (vertex);
while (!q.IsDone ()) {
Edge& edge = dynamic_cast<Edge&> (*q);
Vertex& to = edge.V1 ();
if (--inDegree [to] == 0)
queue.Enqueue (to);
++q;
}
delete &q;
}
delete &queue;
}
示例2: Accept
void ListAsArray::Accept(Visitor& visitor) const
{
for(unsigned int i = 0 ; i < count ; ++i){
visitor.Visit(*array[i]);
}
}
示例3: Visit
void Visit(Visitor &visitor)
{
for(unsigned int i = 0; i < this->Items.size(); ++i)
{
visitor.Visit(this->Items[i]);
}
}
示例4: Accept
void StackAsArray::Accept (Visitor& visitor) const
{
for (unsigned int i = 0; i < count && !visitor.IsDone (); ++i)
{
visitor.Visit (*array [i]);
}
}
示例5: Accept
void ListAsArray::Accept(Visitor& visitor) const
{
for(unsigned int i = 0; i < nCount && !visitor.IsDone(); i++)
{
visitor.Visit(*(array[i]));
}
}
示例6: Accept
void BagAsLinkedList::Accept (Visitor& visitor) const
{
ListElement<Object*> const* ptr;
for (ptr = list.Head (); ptr != 0 && !visitor.IsDone (); ptr = ptr->Next())
{
visitor.Visit (*ptr->Datum ());
}
}
示例7: VisitChildren
bool DirSelect::VisitChildren(Visitor &visitor, bool /*onlyVisible*/)
{
for (size_t x=0; x<items.size(); x++) {
if (!visitor.Visit(objects[x])) {
return false;
}
}
return true;
}
示例8: VisitChildren
bool PopupGroup::VisitChildren(Visitor &visitor, bool /*onlyVisible*/)
{
if (main!=NULL) {
if (!visitor.Visit(main)) {
return false;
}
}
return true;
}
示例9: VisitChildren
bool Multi::VisitChildren(Visitor &visitor, bool onlyVisible)
{
if (onlyVisible) {
if (model.Valid() &&
!model->IsNull() &&
!visitor.Visit(list[model->GetUnsignedLong()])) {
return false;
}
}
else {
for (size_t x=0; x<list.size(); x++) {
if (!visitor.Visit(list[x])) {
return false;
}
}
}
return true;
}
示例10: VisitChildren
bool Table::VisitChildren(Visitor &visitor, bool onlyVisible)
{
if (hScroller!=NULL && (!onlyVisible || hVisible)) {
if (!visitor.Visit(hScroller)) {
return false;
}
}
if (vScroller!=NULL && (!onlyVisible || vVisible)) {
if (!visitor.Visit(vScroller)) {
return false;
}
}
if (object!=NULL) {
if (!visitor.Visit(object)) {
return false;
}
}
return true;
}
示例11: BreadthFirstTraversal
void Tree::BreadthFirstTraversal (Visitor& visitor) const
{
Queue& queue = *new QueueAsLinkedList ();
queue.RescindOwnership ();
if (!IsEmpty ())
queue.Enqueue (const_cast<Tree&> (*this));
while (!queue.IsEmpty () && !visitor.IsDone ())
{
Tree const& head = dynamic_cast<Tree const &> (queue.Dequeue ());
visitor.Visit (head.Key ());
for (unsigned int i = 0; i < head.Degree (); ++i)
{
Tree& child = head.Subtree (i);
if (!child.IsEmpty ())
queue.Enqueue (child);
}
}
delete &queue;
}
示例12: Accept
void TypedefNode::Accept(Visitor& visitor)
{
visitor.Visit(*this);
}
示例13: Accept
void BoundConjunctiveConstraint::Accept(Visitor& visitor)
{
Left()->Accept(visitor);
Right()->Accept(visitor);
visitor.Visit(*this);
}
示例14: Accept
void Accept(Visitor& v) override
{
v.Visit(*this);
}
示例15: Accept
void DepartmentZ::Accept(Visitor& externalTrainer) {
externalTrainer.Visit(*this);
}