fbpx
Wikipedia

Range (computer programming)

In computer science, the term range may refer to one of three things:

  1. The possible values that may be stored in a variable.
  2. The upper and lower bounds of an array.
  3. An alternative to iterator.

Range of a variable Edit

The range of a variable is given as the set of possible values that that variable can hold. In the case of an integer, the variable definition is restricted to whole numbers only, and the range will cover every number within its range (including the maximum and minimum). For example, the range of a signed 16-bit integer variable is all the integers from −32,768 to +32,767.

Range of an array Edit

When an array is numerically indexed, its range is the upper and lower bound of the array. Depending on the environment, a warning, a fatal exception, or unpredictable behavior will occur if the program attempts to access an array element that is outside the range. In some programming languages, such as 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 Edit

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".[1] It is argued [1] that "Ranges are a superior abstraction" (compared to iterators) for several reasons, including better safety.

In particular, such ranges are supported in C++20,[2] Boost C++ Libraries[3] and the D standard library.[4]

See also Edit

References Edit

  1. ^ a b Andrei Alexandrescu (6 May 2009). "Iterators Must Go" (PDF). BoostCon 2009. Retrieved 29 July 2014.
  2. ^ cppreference
  3. ^ Boost.Range documentation
  4. ^ D Phobos Runtime Library std.range module


range, computer, programming, this, article, needs, additional, citations, verification, please, help, improve, this, article, adding, citations, reliable, sources, unsourced, material, challenged, removed, find, sources, range, computer, programming, news, ne. This article needs additional citations for verification Please help improve this article by adding citations to reliable sources Unsourced material may be challenged and removed Find sources Range computer programming news newspapers books scholar JSTOR December 2006 Learn how and when to remove this template message In computer science the term range may refer to one of three things The possible values that may be stored in a variable The upper and lower bounds of an array An alternative to iterator Contents 1 Range of a variable 2 Range of an array 3 Range as an alternative to iterator 4 See also 5 ReferencesRange of a variable EditThe range of a variable is given as the set of possible values that that variable can hold In the case of an integer the variable definition is restricted to whole numbers only and the range will cover every number within its range including the maximum and minimum For example the range of a signed 16 bit integer variable is all the integers from 32 768 to 32 767 Range of an array EditMain article Array data type Indexing notation When an array is numerically indexed its range is the upper and lower bound of the array Depending on the environment a warning a fatal exception or unpredictable behavior will occur if the program attempts to access an array element that is outside the range In some programming languages such as 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 EditAnother 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 1 It is argued 1 that Ranges are a superior abstraction compared to iterators for several reasons including better safety In particular such ranges are supported in C 20 2 Boost C Libraries 3 and the D standard library 4 See also EditIntervalReferences Edit a b Andrei Alexandrescu 6 May 2009 Iterators Must Go PDF BoostCon 2009 Retrieved 29 July 2014 cppreference Boost Range documentation D Phobos Runtime Library std range module nbsp This computer programming related article is a stub You can help Wikipedia by expanding it vte Retrieved from https en wikipedia org w index php title Range computer programming amp oldid 1145466532, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.