Giter Site home page Giter Site logo

pavelkryukov / forward_list2 Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 135 KB

C++ std::forward_list with push_back and before_end

Home Page: https://pavelkryukov.github.io/forward_list2/

License: MIT License

C++ 99.56% Makefile 0.44%
linked-list linked-lists stl-containers stl forward-list linked-list-in-cpp cpp23 cpp26 boost

forward_list2's Introduction

codecov

forward_list2

Wrapper around C++ std::forward_list which adds an iterator to the last element.

The idea has been proposed and discussed here: cpp-ru/ideas#487.

Extra functions

const_reference back() const;

const_iterator before_end() const noexcept;
const_iterator cbefore_end() const noexcept;

void push_back(const T& value);
void push_back(T&& value);

template<class... Args>
reference emplace_back(Args&&... args);

Price

  • Compute time overheads to maintain the iterator to the last element.
  • Extra O(N) traversals on copy assignment and sorting.
  • Memory size overhead on empty container:
static_assert(sizeof(std::forward_list<int>) == sizeof(void*));
static_assert(sizeof(forward_list2<int>) == 2 * sizeof(void*));

Limitations

  • No reference back(); is available since it would require passing non-constant iterator to erase_after.

Impact

forward_list2's People

Contributors

pavelkryukov avatar

Watchers

 avatar  avatar

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.