11. (STL Compatibility and Emulation, Project) Using the design philosophy underlying the STL algorithms will improve the...

Question:

11. (STL Compatibility and Emulation, Project)

Using the design philosophy underlying the STL algorithms will improve the quality of the code for lattice ADTs and make the code less redundant.

Answer the following questions:

a) Modify the lattice ADTs to make them STL compatible.

b) Test the new functionality by writing a function (similar to std::transform()) that applies a real-valued function of one variable to each node of a source lattice to either modify that lattice or initialise a destination lattice.We use iterators in the style of STL by modifying the following code:

template

void transform(Lattice& lattice, const std::function& f)

{ // Apply a function to each node of lattice, modifying it for (std::size_t n = lattice.MinIndex(); n <= lattice.

MaxIndex(); ++n)

{

for (std::size_t i = 0; i < lattice[n].size(); ++i)

{

lattice[n][i] = f(lattice[n][i]);

}

}

}

c) What are the advantages of having STL-compatible containers?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: