RustBrock/Collection of Common Data Structs.md
2025-01-17 20:51:38 -07:00

864 B

Collection of Common Data Structs

The std library includes a number of useful data structures called collections

Collections can contain multiple values unlike built in array and tuples types these are all stored on the heap which means the amount of data does not need to be known at compile time and can grow or shrink as the program runs

each kind of collection has different capabilities and cost choosing the right one is a skill that is developed over time

Common Collections

  • Vector - allows for storing a variable number of values next to each other
  • String - a collection of characters
  • Hash Map - allows you to associate a value with a specific key
    • Its particular implementation is a more general version of a general data struct called a map
      • {
      • 1: data,
      • 2: more_data,
      • 3: this is a map
      • }