sábado, 19 de julio de 2014

Sentinel value

In computer programming, a sentinel value (also referred to as a flag value, trip value, rogue value, signal value, or dummy data) is a special value whose presence guarantees termination of a loop that processes structured (especially sequential) data. The sentinel value makes it possible to detect the end of the data when no other means to do so (such as an explicit size indication) is provided. The value should be selected in such a way that it is guaranteed to be distinct from all legal data values, since otherwise the presence of such values would prematurely signal the end of the data.
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
A negative integer for indicating the end of a sequence of non-negative integers
End-of-file, a non-character value returned by
...

No hay comentarios:

Publicar un comentario