Re: [Patch] RBTree iteration interface improvement - Mailing list pgsql-hackers

From Aleksander Alekseev
Subject Re: [Patch] RBTree iteration interface improvement
Date
Msg-id 20160728180023.7f452258@fujitsu
Whole thread Raw
In response to Re: [Patch] RBTree iteration interface improvement  (Amit Kapila <amit.kapila16@gmail.com>)
Responses Re: [Patch] RBTree iteration interface improvement
List pgsql-hackers
> Can you explain use case where you need it?

Sure. You can consider RBTree as a container that always keeps its
elements in sorted order.  Now imagine you would like to write a code
like this:

```
/* iterate over items in sorted order */
while(item1 = left_right_walk(tree))
{
 /* another iteration, probably even in different procedure */ while(item2 = left_right_walk(tree)) {   /* ... some
logic... */ }
 

}
```

Currently you can't do it.

Or maybe you have different objects, e.g. IndexScanDesc's, that should
iterate over some tree's independently somewhere in indexam.c
procedures. Exact order may depend on user's query so you don't even
control it.

-- 
Best regards,
Aleksander Alekseev



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_upgrade: exit_hook_registered variable
Next
From: Alex Ignatov
Date:
Subject: Re: Why we lost Uber as a user