pl_search_cpp 1.4
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
pl_search::CList Class Reference

Represents a list of terms. More...

#include <clist.hpp>

Inheritance diagram for pl_search::CList:
Inheritance graph
[legend]
Collaboration diagram for pl_search::CList:
Collaboration graph
[legend]

Public Member Functions

 CList (std::list< TermPtr > &elems)
 Constructs a CList with the given elements.
 
std::string repr () const override
 Returns a string representation of the list.
 
bool isEqualTo (Term &other) const override
 Checks if the term is equal to another term.
 
bool isLessThan (Term &other) const override
 < operator for a CList and a Term
 
void addElement (TermPtr element)
 Adds an element to the list.
 
const std::list< TermPtr > & getElements () const
 Returns the elements of the list.
 
- Public Member Functions inherited from pl_search::Term
virtual TermPtr dereference ()
 Dereferences the term. The default is to return a shared pointer to term itself.
 
virtual bool unifyWith (Engine *engine, TermPtr t)
 A hook for unification of user-defined classes. Only override this method if you want to unify user-defined classes.
 
virtual bool is_var ()
 Checks if the term is a variable.
 
 Term ()
 Default constructor.
 
virtual ~Term ()
 Virtual destructor for proper cleanup.
 

Protected Attributes

std::list< TermPtr > & elements
 The elements of the list.
 

Additional Inherited Members

- Protected Member Functions inherited from pl_search::Term
virtual Termderef_term ()
 Similar to dereference but returning the "raw" pointer.
 

Detailed Description

Represents a list of terms.

CList objects replace Prolog lists for efficiency. The internal list is mutable, so care must be taken when using CList objects. For example, it might be necessary to copy the list before passing it to a function that might modify it or when binding a variable to a CList object.

Constructor & Destructor Documentation

◆ CList()

pl_search::CList::CList ( std::list< TermPtr > &  elems)
inline

Constructs a CList with the given elements.

Parameters
elemsThe elements of the list.

Member Function Documentation

◆ addElement()

void pl_search::CList::addElement ( TermPtr  element)
inline

Adds an element to the list.

Parameters
elementThe element to add. Warning: the engine does not backtrack over adding elements to a CList.

◆ getElements()

const std::list< TermPtr > & pl_search::CList::getElements ( ) const
inline

Returns the elements of the list.

Returns
A reference to the list of elements.

◆ isEqualTo()

bool pl_search::CList::isEqualTo ( Term other) const
inlineoverridevirtual

Checks if the term is equal to another term.

Parameters
otherThe term to compare to.
Returns
True if the terms are equal, false otherwise.

Implements pl_search::Term.

◆ isLessThan()

bool pl_search::CList::isLessThan ( Term other) const
overridevirtual

< operator for a CList and a Term

Parameters
otherThe term being compared
Returns
True if the this CList is < other, false otherwise.

Implements pl_search::Term.

◆ repr()

std::string pl_search::CList::repr ( ) const
inlineoverridevirtual

Returns a string representation of the list.

Returns
A string representation of the list.

Reimplemented from pl_search::Term.

Member Data Documentation

◆ elements

std::list<TermPtr>& pl_search::CList::elements
protected

The elements of the list.


The documentation for this class was generated from the following files: