#How to create a stack

1 messages · Page 1 of 1 (latest)

vapid mist
#

?

hexed island
#

std.ArrayList

vapid mist
#

Okay

#

@hexed island what is the difference between arraylist and arraylist aligned?

runic isle
#

ArrayListAligned lets you choose the alignment of the items within, ArrayList is an ArrayListAligned with the alignment being the natural alignment of the type

vapid mist
#

i dont understand can u explain with example?

spiral field
#

In general its very niche

vapid mist
#

in general we give ArrayList(u8) right?

#

then how we give for arraylist aligned ?

spiral field
#

If you want to know, id recommend reading: https://en.m.wikipedia.org/wiki/Data_structure_alignment

Data structure alignment is the way data is arranged and accessed in computer memory. It consists of three separate but related issues: data alignment, data structure padding, and packing.
The CPU in modern computer hardware performs reads and writes to memory most efficiently when the data is naturally aligned, which generally means that the da...

vapid mist
#

alignment being how much space do i need to go forward to get other element?

spiral field
vapid mist
#

@spiral field So for our own data structures we need an alignment right to get next element we need to skip size of our struct ?

lofty ice
spiral field
#

Interesting
Wikipedia is kinda my go to but that might be better i havent read it

vapid mist
#

But in C/C++ we dont talk about alignment right? Does it automatically manages the alignment?

hexed island
#

Depending on what you do in C/C++, you sometimes do talk about alignment

#

For many use-cases, it's handled for you, like in std.ArrayList

vapid mist
#

ok

spiral field