Sequence of boost::logic::tribools - let indeterminate entries inherit from their neighbours
Hi, I have a sequence of tribools and I want element with a indeterminate value to inherit from their neighbours. Does such an algorithm exist already in Boost? If not, do you think it would be a useful addition? BR, Jens
Am 06.05.2014 22:22, schrieb Nat Goodspeed:
On Mon, May 5, 2014 at 2:11 PM, Jens Müller
wrote: I have a sequence of tribools and I want element with a indeterminate value to inherit from their neighbours. Hmm, so they pass on "tribool knowledge"?
(sorry)
Sort of, yeah. My current idea is actually a sort of proxy output iterator which keeps a counter of "pending" indeterminate tribools and flushes them to the proxied output iterator once their status becomes known. It should also automatically flush in it's destructor. Then I could just use std::copy with a std::back_inserter in order to convert a sequence including indeterminate values into a sequence just containing bools. Useful? BR, Jens
On May 8, 2014, at 6:43 AM, Jens Müller
My current idea is actually a sort of proxy output iterator which keeps a counter of "pending" indeterminate tribools and flushes them to the proxied output iterator once their status becomes known. It should also automatically flush in it's destructor.
Then I could just use std::copy with a std::back_inserter in order to convert a sequence including indeterminate values into a sequence just containing bools.
Useful?
Whether it's generally useful depends on the kinds of use cases it addresses. It's an intriguing idea, but I haven't yet imagined an application in which I'd want that. Sorry, limited imagination... please suggest a few?
Am 08.05.2014 14:17, schrieb Nat Goodspeed:
On May 8, 2014, at 6:43 AM, Jens Müller
wrote: My current idea is actually a sort of proxy output iterator which keeps a counter of "pending" indeterminate tribools and flushes them to the proxied output iterator once their status becomes known. It should also automatically flush in it's destructor.
Then I could just use std::copy with a std::back_inserter in order to convert a sequence including indeterminate values into a sequence just containing bools.
Useful? Whether it's generally useful depends on the kinds of use cases it addresses. It's an intriguing idea, but I haven't yet imagined an application in which I'd want that. Sorry, limited imagination... please suggest a few?
My use case is a direction filter in a route-time diagram. The directions can be "along the filter direction", "against the filter direction" or "no direction" (because the line segment is parallel to the time axis, i.e., it represents a stopping object). I want undirected line segments to be visible if they are next to a visible directed line segment. So after matching the line segments against the direction filter, their visibily is true, false or indeterminate. After applying the inheritance transformation, visibility is either true or false, with undirected line segments (stops) having the correct visibility. BR, Jens
On 08.05.2014 12:43, Jens Müller wrote:
My current idea is actually a sort of proxy output iterator which keeps a counter of "pending" indeterminate tribools and flushes them to the proxied output iterator once their status becomes known. It should also automatically flush in it's destructor.
I did just that: A function object with a just three member variables: a pending count, the "last real value" bool, and an output iterator. And then I wrapped this in a boost::function_output_iterator.
Then I could just use std::copy with a std::back_inserter in order to convert a sequence including indeterminate values into a sequence just containing bools.
Actually, I am using it in a std::transform now (instead of a std::copy, a simple std::foreach with the function object would have sufficed), so that I can directly compute the visibility (as tribool) of the elements.
participants (2)
-
Jens Müller
-
Nat Goodspeed