Data structures and opaque types - Fish-In-A-Suit/Conquest GitHub Wiki
Data stucture is a particular way of storing data in a computer so that it can be accessed and modified efficiently. It is a collection of data values, the relationships between them and the operations that can be performed on the data.
There are various different data structures, which are mostly built upon simpler primitive data types:
- array: a number of same- data -typ elements in a specific order.
- linked list: a linear connection of various different types of data types
- struct (also called a "record" or a "tuple") is a value that contains other values, typically in fixed number and sequence and indexed by names. The elements of a struct are called fields or members. For example, the struct GLFWVidMode contains width, height,
- union: is a data structure that specifies which of a number of permitted primitive types may be stored in its instances, e.g. float or long integer. Contrast with a record, which could be defined to contain a float and an integer; whereas in a union, there is only one value at a time
- class: is a data structure that contains data fields, like a struct, as well as various methods which operate on the contents of the record. In the context of object-oriented programming, records are known as plain old data structures to distinguish them from classes
Opaque types
In computer science, an opaque data type is a data type whose concrete data structure is not defined in an interface. This enforces information hiding, since its values can only be manipulated by calling subroutines that have access to the missing information. The concrete representation of the type is hidden from its users, and the visible implementation is incomplete. A data type whose representation is visible is called transparent (opposite to opaque).
An opaque class could be visualised as a class which has all of it's fields private, while the methods for accessing the values of those fields public. The only thing which programmer can do in such case is to take the memory address of that object, to produce an opaque pointer and then call the methods for that data type through that pointer.
A pointer is a variable (or object) whose value refers to (or points to) an another value - the memory address of another object (for example, long window;
, which holds the memory address of the monitor). Obtaining the value of that memory address is known as deferencing the pointer.
An opaque pointer is a pointer referencing an opaque type (class).