lkml.org 
[lkml]   [2019]   [Nov]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 02/10] lib: introduce generic min max heap
On Wed, Nov 13, 2019 at 04:30:34PM -0800, Ian Rogers wrote:
> +/*
> + * Remove the minimum element and then push the given element. The
> + * implementation performs 1 sift (O(log2(size))) and is therefore more
> + * efficient than a pop followed by a push that does 2.
> + */
> +static void heap_pop_push(struct min_max_heap *heap,
> + const void *element,
> + const struct min_max_heap_callbacks *func)
> +{
> + char *data = (char *)heap->data;
> +
> + memcpy(data, element, func->elem_size);
> + heapify(heap, 0, func);
> +}

I'm not a fan of this operation. It has a weird name and it is utterly
trivial.

\
 
 \ /
  Last update: 2019-11-14 10:36    [W:0.336 / U:1.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site