pl_search_cpp 1.7
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
 
const std::list< TermPtrgetElements () const
 Gets 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< TermPtrelements
 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 list passed to the constructor is copied.

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

◆ getElements()

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

Gets the elements of the list.

The elements are returned as a list of shared pointers to Terms. The caller can modify the elements of the list through the shared pointers, but cannot modify the list itself. Making the list itself modifiable would break the immutability of CList, which is a key feature for its use in Prolog-like logic programming. This means that any changes to the list will be undone on backtracking, which is essential for the correct functioning of the engine. If users need to modify the list itself, they should create a new CList with the modified list of elements.

Returns
The elements of the list.

◆ 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: