Content deleted Content added
edit |
Added section on ranges as in ''Boost Ranges" |
||
Line 11:
When an array is numerically [[Index (information technology)|indexed]], its range is the upper and lower bound of the array. Depending on the environment, a warning, a [[fatal error]], or unpredictable behavior will occur if the program attempts to access an array element that is outside the range. In some languages, such as [[C (programming language)|C]], arrays have a fixed lower bound (zero) and will contain data at each position up to the upper bound (so an array with 5 elements will have a range of 0 to 4). In others, such as [[PHP]], an array may have holes where no element is defined, and therefore an array with a range of 0 to 4 will have ''up to'' 5 elements (and a minimum of 2).
== Range as an alternative to iterator ==
Another meaning of ''range'' in computer science is an alternative to [[iterator]]. When used in this sense, range is defined as "a pair of begin/end iterators packed together" <ref name="itersmustgo">[http://www.boostcon.com/site-media/var/sphene/sphwiki/attachment/2009/05/08/iterators-must-go.pdf Iterators Must Go, Andrei Alexandrescu, BoostCon 2009]</ref>. It is argued <ref name="itersmustgo" /> that "Ranges are a superior abstraction" (compared to iterators) for several reasons, including better safety.
In particular, such ranges are supported in [[Boost C++ Libraries]] <ref>[http://www.boost.org/doc/libs/1_35_0/libs/range/doc/intro.html Boost.Range documentation]</ref>.
== References ==
{{reflist}}
==See also==
|