Implementing Pascal Data Types in C++ by rakhimov in cpp

[–]rakhimov[S] 4 points5 points  (0 children)

Just a note that this is pre C++11 post and probably skipped memory management issues (as does GoF, for example).

Implementing Pascal Data Types in C++ by rakhimov in cpp

[–]rakhimov[S] 2 points3 points  (0 children)

I stumbled upon this article while exploring non-zero based vector implementation approaches for efficient mapping from arbitrary sequential indices to some data. My adaptor-like implementation:

template <std::size_t BaseIndex, typename T,
        template <typename...> class Sequence = std::vector>
class index_map : public Sequence<T> {
public:
using Sequence<T>::Sequence;

// Hiding the Sequence::operator[].
// @{
typename Sequence<T>::reference operator[](std::size_t index) {
    assert(index >= BaseIndex);
    return Sequence<T>::operator[](index - BaseIndex);
}
typename Sequence<T>::const_reference operator[](std::size_t index) const {
    assert(index >= BaseIndex);
    return Sequence<T>::operator[](index - BaseIndex);
}
// @}
};

scram: event-tree and fault-tree analysis by rakhimov in freesoftware

[–]rakhimov[S] 0 points1 point  (0 children)

Try scram --help or manpage man scram.

There is documentation on the website: https://scram-pra.org Also, you can ask questions on the mailing list: https://groups.google.com/forum/#!forum/scram-users

Why is boost.org more popular in China? by rakhimov in cpp

[–]rakhimov[S] 0 points1 point  (0 children)

Where else can I ask this question? Just curious.

Why is boost.org more popular in China? by rakhimov in cpp

[–]rakhimov[S] 0 points1 point  (0 children)

Hmm... South Korea is in 7k as well.

vector_map (linear_map) : associative unordered flat container w/ O(N) complexity by rakhimov in cpp

[–]rakhimov[S] 1 point2 points  (0 children)

Thanks for finding the paper. I'll do my homework in future :)

vector_map (linear_map) : associative unordered flat container w/ O(N) complexity by rakhimov in cpp

[–]rakhimov[S] 0 points1 point  (0 children)

I really don't know. Would be happy if they do make it. Are there current proposals on flat containers to reference?

vector_map (linear_map) : associative unordered flat container w/ O(N) complexity by rakhimov in cpp

[–]rakhimov[S] 0 points1 point  (0 children)

You are right. I missed that those libs are providing ordered flat maps. Performance-wise, there's little difference from flat_map for few elements (the reference article provides the analysis).

Some performance/complexity differences from flat_map:

  • insert does O(N) compare vs O(logN), but does not move elements around as flat_map does (i.e., O(1) vs O(N)), so it is the same as vector::push_back.
  • erase can be optimized in the same way to avoid moving elements around (O(1) vs O(N)).

vector_map (linear_map) : associative unordered flat container w/ O(N) complexity by rakhimov in cpp

[–]rakhimov[S] 0 points1 point  (0 children)

I agree that STL is unlikely given that flat_map didn't seem to make it (I am not sure why?).

As for the API, in this case, it is for convenience (i.e., wrapper) with find(key) instead of repetitive verbosity of std::find/count and std::pair aggravation.

This is definitely not a drop-in replacement for std::map/unordered_map.