Code Monkey home page Code Monkey logo

advanced-programming's People

Contributors

asartori86 avatar bebosudo avatar ffranchina avatar pgallir avatar

Watchers

 avatar  avatar  avatar

advanced-programming's Issues

Implementation of iterators

Hello @asartori86!
Me and @bebosudo were thinking about a good implementation of iterators for the binary search tree class. We thought about many different possibilities, each with its pros and cons.

In particular we ended up dividing the implementations into two main categories:

  • the ones that "duplicate" the structure so that, even if the tree is modified after the instantiation, the output of the iterator stays the same
  • the ones that work "online" and, if the structure is altered, they adapt accordingly and give data always consistent with the modified structure

For example, consider the following code:

// insertion of number from 1 to 20 into the tree...

for (IteratorClass it = tree.begin(); it->key() < 10; it++) { cout<<it; }

tree.erase(15);

for (; it != tree.end(); it++) { cout<<it;  }

in the first case would print all the numbers from 1 to 20, since the tree nodes have been copied elsewhere at the iterator initialization;
in the second case it would print numbers from 1 to 20, 15 excluded, when using the second method.

Both of the approaches presents a trade-off of the kind flexibility vs memory-frugality.
Would it be possible to have your opinion about that?
Thank you in advance for your time!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.