Skip to main content
Engineering LibreTexts

10: Arrays

  • Page ID
    76141
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    In HLLs, there is a concept of a multi-valued variables. These multi-valued variables are a single variable that contains other variables. These multi-valued variables include structures such as an array, a structure or a class, or most common data structures such as stacks, queues, heaps, etc.

    An array is a generally builtin into a language, and contains multiple values of the same type for primitive values, or extend or implement a base class or interface for objects. The dereference operator is a pair a square brackets, “[]”, and for the purposes here the values are referenced by an index specifying a distance from the base of the array.

    A structure or class is generally built into a language, contains a fixed number of other variables, all of which can have different types. The dereference operator is a “.”, and the values are named variables that are contained in that structure or class.

    A data structure is generally not built into a language, and contains an indeterminate number of variables. Because the data structures are generally built as programs in a given language, there is a lot of variation on how they behave. The access to the contained variables is generally implemented using function and the “.” dereference operator, but this can vary widely depending of the language. For most languages, all the variables contained extend or implement a base class or interface for objects, though some HLL like C/C++ allow the data structure to contain primitive variables. Finally the rules for how to store and access the data vary widely across different types of data structures.

    This chapter will only deal with arrays which will be restricted to implementation containing primitive data values and use standard base + offset addressing.


    This page titled 10: Arrays is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Charles W. Kann III via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.

    • Was this article helpful?