Sunday, November 9, 2008

Chapter 4, Lesson 2 and 3

I'm grouping together some of the lessons here as they all shared the same subject: Collections, lists and dictionaries.

Lesson 2 covered the sequantial lists: Stack and Queue. Very easy, very simple.

A Queue is a FIFO type of collection where items get put into the queue and pulled out again.A Stack is LIFO type of collectioins where items get pushed onto the stack and popping them of again.

A memory tip: Queue is a line at a bank while Stack is a Stack of cards.

Lesson 3 was a bit more complicated as it covered Dictionaries. The Hashtable is the most important dictionary.

Really interessting was the part where they explained how equality and default ordering is implemented by the Hashtable.

What I remember from it was that Hashtable doesn't allow duplicate keys in the collection, but these keys are in fact the hashes (GetHashValue method) of those items.Take control over equality by implementing a IEqualityComparer interface.

See you soon.

No comments: