Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Learning D - Data Structures


Everything in D is centered around the idea of data. Your process data from the user or files and you produce your own data from that. This could be a game creating images based upon a player's movement, a web server getting input from a web browser and sending files over the internet, or it could even be a media player reading a song and playing it back to the user.

Understanding data structures will help you to know what you need to accomplish your goals and what data structures you can put together to do that.

Numeric Data Structures

nameexplanation
bytesigned 8 bits
ubyteunsigned 8 bits
shortsigned 16 bits
ushortunsigned 16 bits
intsigned 32 bits
uintunsigned 32 bits
longsigned 64 bits
ulongunsigned 64 bits
centsigned 128 bits (reserved for future use)
ucentunsigned 128 bits (reserved for future use)
float32 bit floating point
double64 bit floating point
reallargest hardware implemented floating point size (Implementation Note: 80 bits for Intel CPUs)
ifloatimaginary float
idoubleimaginary double
irealimaginary real
cfloata complex number of two float values
cdoublecomplex double
crealcomplex real

Textual Data Structures

charcharacter
wcharwide character
dcharD character
(dchar/wchar/char)[]string

Collection Data Structures

[]Array
[ void ]Associative Array
N/ATuple

Boolean Data

boolboolean value

Structs

Structs are Custom Data Structures

Classes

Classes are Custom Data Structures

Pointers and Void Type Data Structures

*the address of the data structure
voidno type needed, it could be any data structure

Functions

Functions are Unique

Next: Numeric Data in D?