libcds icon indicating copy to clipboard operation
libcds copied to clipboard

Library usage

Open cgurps opened this issue 5 years ago • 2 comments

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?

cgurps avatar May 18 '20 18:05 cgurps

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.

khizmax avatar May 18 '20 18:05 khizmax

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

cgurps avatar May 18 '20 19:05 cgurps