Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Better name needed for applying a function on elements of a container

I have a container class (containing a multi-index container) for which I have a public "foreach" member-function, so users can pass a functor to apply on all elements.
While implementing, I had a case where the functor should only be applied to some elements of a range in the container, so I overloaded the foreach, to pass some valid range.
Now, in some cases, it was worthwhile to stop on a certain condition, so practically, I let the foreach stop based on the return-value of the function.

I'm pleased with how the system works, but I have one concern:
How should a "foreach" on a range, with stop conditions be called?
Anyone knows a generic, clear and concise name?

like image 579
stefaanv Avatar asked May 26 '10 09:05

stefaanv


People also ask

What is the use of container component?

It renders the corresponding component Sometimes, the container component can perform two functions (i.e. to render UI and hold logic). In a situation where a container component performs these. The component itself does not hold too many markups (JSX) and is void of CSS styles.

What is applying a function to each element of a list?

Let’s see what exactly is Applying a function to each element of a list means: Suppose we have a list of integers and a function that doubles each integer in this list. On applying the function to the list, the function should double all the integers in the list.

What is the difference between a function and a container?

A container can contain anything, from a webservice, to a million LOC monolith, to a complete DBMS system, to the data tier that DBMS writes into. These containers can live forever, scale horizontally (or not), take 20 minutes to start, 20 days to run, and on and on. Contrast this to a Function, which typically has a set of known characteristics:

What is the use of container in react?

Container components can be primarily referred to as the parent elements of other components in a React app. They serve as a bridge between the normal components that render the UI and the logic that makes the UI components interactive and dynamic. The most common function of a container component is to obtain data.


3 Answers

Based on your description, i'd go for apply_until().

like image 143
Georg Fritzsche Avatar answered Sep 30 '22 20:09

Georg Fritzsche


Maybe until or something?

like image 35
Andreas Brinck Avatar answered Sep 30 '22 19:09

Andreas Brinck


How about find_if(...), as in stl ?

like image 32
Viktor Sehr Avatar answered Sep 30 '22 21:09

Viktor Sehr