Sentinel value

Sentinel value

In computer programming, a sentinel value (also referred to as a flag value, rogue value, or signal value)Fact|date=April 2007 is a special value that is used to terminate a loop that processes structured (especially sequential) data. The value should be selected in such a way that it will not be confused with legal data values.

Below are some examples of common sentinel values and their uses:
* Null character for indicating the end of a null-terminated string.
* Null pointer for indicating the end of a linked list.
* The empty list, (), in Lisp and its variants.

Sentinel values are often used when searching for something of importance. [McConnell, Steve. "Code Complete" Edition 2 Pg. 621 ISBN - 0-7356-1967-0]

In safe languages, most uses of sentinel values could be replaced with option types, which enforce explicit handling of the exceptional case.

See also

* Sentinel node

Notes


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • Sentinel node — A sentinel node is a programming idiom used to speed up some operations on linked lists and trees. It refers to a special type of object that represents the end of a data structure. Linked list data structures may use a sentinel object to… …   Wikipedia

  • Sentinel Management Group — is a cash management firm based in Northbrook, Illinois. Sentinel invests for clients such as managed futures funds, high net worth individuals and hedge funds that want to be able to withdraw their cash quickly. Investments include short term… …   Wikipedia

  • Pointer (computing) — This article is about the programming data type. For the input interface (for example a computer mouse), see Pointing device. Pointer a pointing to the memory address associated with variable b. Note that in this particular diagram, the computing …   Wikipedia

  • Associative array — In computer science, an associative array (also called a map or a dictionary) is an abstract data type composed of a collection of (key,value) pairs, such that each possible key appears at most once in the collection. Operations associated with… …   Wikipedia

  • Tagged union — In computer science, a tagged union, also called a variant, variant record, discriminated union , or disjoint union, is a data structure used to hold a value that could take on several different, but fixed types. Only one of the types can be in… …   Wikipedia

  • Infinity — In mathematics, infinity is often used in contexts where it is treated as if it were a number (i.e., it counts or measures things: an infinite number of terms ) but it is a different type of number from the real numbers. Infinity is related to… …   Wikipedia

  • Option type — For families of option contracts in finance, see Option style. In programming languages (especially functional programming languages) and type theory, an option type or maybe type is a polymorphic type that represents encapsulation of an optional …   Wikipedia

  • Stack (data structure) — In computer science, a stack is an abstract data type and data structure based on the principle of Last In First Out (LIFO) . Stacks are used extensively at every level of a modern computer system. For example, a modern PC uses stacks at the… …   Wikipedia

  • Data domain — For other uses, see Data domain (disambiguation). In data management and database analysis, a data domain refers to all the unique values which a data element may contain. The rule for determining the domain boundary may be as simple as a data… …   Wikipedia

  • Stdarg.h — is a header in the C standard library of the C programming language that allows functions to accept an indefinite number of arguments. C++ provides this functionality in the header ; the C header, though permitted, is deprecated in C++.The… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”