Wednesday, 11 February 2015

F452 - Arrays 'n' stuff.

3 properties of a 1 dimensional array:


  • List of elements of a specific type.
  • Can be used in an expression.
  • Contiguous block of memory.
  • Relatively efficient (not entirely guaranteed).
  • Typed.
  • Has an identifier.
  • Indexes (mainly 0 based0).
  • Fixed size.



2D array:

Row then column.
2 columns.

A      B
[0,0],[1,0],
[1,0],[1,1],

[2,0],[2,1],



List:

Efficient and dynamic data type.

Dictionary:
This is an implementation of a hash table: an extremely efficient way to store keys for lookup.
A dictionary is fast, well designed and reliable.
Example: dict["string"];

ArrayList:
Found in systems.collections. Can have different data types.

Stack:
Sequential stack where data is pushed and popped to the top of the stack.

Queue:
This removes elements that were added first (FIFO, first-in-first out). So we keep items in order.

Sets:
The hashset implements set logic in its many instance methods. We use methods such as Union on different HashSets to solve problems. This makes some programs simpler.

No comments:

Post a Comment