OOFEM 3.0
Loading...
Searching...
No Matches
oofem::Dictionary Class Reference

#include <dictionary.h>

Collaboration diagram for oofem::Dictionary:

Public Member Functions

 Dictionary ()
 Constructor, creates empty dictionary.
 ~Dictionary ()
 Destructor.
 Dictionary (const Dictionary &other)
 copy constructor
Dictionaryoperator= (const Dictionary &other)
 copy assignment constructor
void clear ()
 Clears the receiver.
Pairadd (int aKey, double value)
double & at (int aKey)
double at (int aKey) const
bool includes (int aKey) const
void printYourself ()
 Prints the receiver on screen.
void formatAsString (std ::string &str)
 Formats itself as string.
int giveSize ()
 Returns number of pairs of receiver.
void saveContext (DataStream &stream)
void restoreContext (DataStream &stream)

Protected Attributes

Pairfirst
 First pair.
Pairlast
 Last pair.

Friends

std::ostream & operator<< (std ::ostream &out, const Dictionary &r)

Detailed Description

This class implements a linked list whose entries are Pairs (see below).

Dictionaries are typically used by degrees of freedom for storing their unknowns. A dictionary stores its pairs in a linked list form. It knows the first pair (attribute 'first') of the list. It also knows the last one (attribute 'last') in order to append an additional pair fast.

Definition at line 58 of file dictionary.h.

Constructor & Destructor Documentation

◆ Dictionary() [1/2]

oofem::Dictionary::Dictionary ( )
inline

Constructor, creates empty dictionary.

Definition at line 68 of file dictionary.h.

References first, and last.

Referenced by Dictionary(), operator<<, and operator=().

◆ ~Dictionary()

oofem::Dictionary::~Dictionary ( )

Destructor.

Definition at line 45 of file dictionary.C.

References clear().

◆ Dictionary() [2/2]

oofem::Dictionary::Dictionary ( const Dictionary & other)
inline

copy constructor

Definition at line 73 of file dictionary.h.

References add(), Dictionary(), first, oofem::Pair::giveKey(), oofem::Pair::giveNext(), and oofem::Pair::giveValue().

Member Function Documentation

◆ add()

Pair * oofem::Dictionary::add ( int aKey,
double value )

Adds a new Pair with given keyword and value into receiver.

Parameters
aKeykey of new pair
valuevalue of new pair
Returns
New Pair with given keyword and value

Definition at line 79 of file dictionary.C.

References first, includes(), last, and OOFEM_ERROR.

Referenced by oofem::AdditiveManufacturingProblem::add_element_if_not_exists2(), oofem::AdditiveManufacturingProblem::add_node_if_not_exists2(), at(), Dictionary(), oofem::OOFEMTXTInputRecord::giveField(), oofem::XMLInputRecord::giveField(), and operator=().

◆ at() [1/2]

double & oofem::Dictionary::at ( int aKey)

Returns the value of the pair which key is aKey. If requested key doesn't exist, it is created with assigned value 0.

Parameters
aKeyKey for pair.
Returns
Reference to value of pair with given key

Definition at line 103 of file dictionary.C.

References add(), first, oofem::Pair::giveKey(), oofem::Pair::giveNext(), and oofem::Pair::giveValue().

Referenced by restoreContext().

◆ at() [2/2]

double oofem::Dictionary::at ( int aKey) const

◆ clear()

void oofem::Dictionary::clear ( )

Clears the receiver.

Definition at line 52 of file dictionary.C.

References first, and last.

Referenced by oofem::OOFEMTXTInputRecord::giveField(), operator=(), restoreContext(), and ~Dictionary().

◆ formatAsString()

void oofem::Dictionary::formatAsString ( std ::string & str)

Formats itself as string.

Definition at line 168 of file dictionary.C.

References first, oofem::Pair::giveKey(), oofem::Pair::giveNext(), and oofem::Pair::giveValue().

◆ giveSize()

int oofem::Dictionary::giveSize ( )

Returns number of pairs of receiver.

Definition at line 67 of file dictionary.C.

References first, and oofem::Pair::giveNext().

◆ includes()

bool oofem::Dictionary::includes ( int aKey) const

Checks if dictionary includes given key

Parameters
aKeyDictionary key.
Returns
True if receiver contains pair with given key, otherwise false.

Definition at line 135 of file dictionary.C.

References first, oofem::Pair::giveKey(), and oofem::Pair::giveNext().

Referenced by add().

◆ operator=()

Dictionary & oofem::Dictionary::operator= ( const Dictionary & other)
inline

copy assignment constructor

Definition at line 82 of file dictionary.h.

References add(), clear(), Dictionary(), first, oofem::Pair::giveKey(), oofem::Pair::giveNext(), and oofem::Pair::giveValue().

◆ printYourself()

void oofem::Dictionary::printYourself ( )

Prints the receiver on screen.

Definition at line 152 of file dictionary.C.

References first, oofem::Pair::giveNext(), and oofem::Pair::printYourself().

◆ restoreContext()

void oofem::Dictionary::restoreContext ( DataStream & stream)

Restores the receiver contents (state) from given stream.

Exceptions
throwsan ContextIOERR exception if error encountered

Definition at line 218 of file dictionary.C.

References at(), oofem::CIO_IOERR, clear(), oofem::DataStream::read(), and THROW_CIOERR.

◆ saveContext()

void oofem::Dictionary::saveContext ( DataStream & stream)

Saves the receiver contends (state) to given stream.

Exceptions
throwsan ContextIOERR exception if error encountered

Definition at line 182 of file dictionary.C.

References oofem::CIO_IOERR, first, oofem::Pair::giveKey(), oofem::Pair::giveNext(), oofem::Pair::giveValue(), THROW_CIOERR, and oofem::DataStream::write().

◆ operator<<

std::ostream & operator<< ( std ::ostream & out,
const Dictionary & r )
friend

Member Data Documentation

◆ first

Pair* oofem::Dictionary::first
protected

◆ last

Pair* oofem::Dictionary::last
protected

Last pair.

Definition at line 64 of file dictionary.h.

Referenced by add(), clear(), and Dictionary().


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

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011