khizmax / libcds

A C++ library of Concurrent Data Structures
http://libcds.sourceforge.net/doc/cds-api/index.html
Boost Software License 1.0
2.57k stars 360 forks source link

Library usage #148

Open cgurps opened 4 years ago

cgurps commented 4 years ago

Good morning,

this is not an issue but more a question about the library usage. Let's say I have a struct like this:

struct A
{
    //some data
    char* data;

    // and integer used for ordering
    uint32_t size;

    bool operator>(const A& other) const
    {
        return size > other.size;
    }
};

I'm using the LazyList as a container for that struct. The ordering for that list is std::greater<A> (which uses the operator> of the list). Is is possible to use a function that returns an element of the list that is inferior or equal to some input node (like upper_bound does in the standard library)?

In other word, is there a container in libcds that can achieve that?

khizmax commented 4 years ago

Hi, no, libcds containers don't provide functions like upper_bound/lower_bound, only exact match is supported. In concurrent environment these functions don't make sense. For example, I found upper bound for some key but other concurrent thread inserts another key that match better for upper bound.

cgurps commented 4 years ago

Thanks for clarification! In my case I don't really care about the best match, I just need one but your comments makes sense!