Home Again

My little family has been living with my wife’s parents in Bountiful for the past couple of months, because my wife had some complications with her pregnancy of our second child, William. (They are both doing fine now.) Her parents have been very helpful and supportive and I am very grateful that they helped take care of us while Chelsea was incapacitated. It was a good experience and I enjoyed getting to know her parents better.

We moved back into our house in Kaysville last night. It is good to be in a place of our own again, with all our familiar furniture, utensils, and appliances. Still, it doesn’t feel quite like home. We put our house up for sale about the time we moved in with her parents, and it hasn’t sold yet. It has been getting a lot of showings, but no offers. I understand this is pretty typical of the market right now. As part of our preparation to sell the house, we gave up our emotional attachment to it. So, it feels kind of like we are living in a hotel.

I am looking forward to when we can sell the place and buy our next house, and start that new chapter of life. It will be nice to finally settle down again. For now, though, I am just happy to be able to walk around the house in my underwear again.

Jaywalker Sighting

My wife and I were driving up to the University Hospital in Salt Lake City yesterday afternoon. As we were heading up South Temple street in the Avenues neighborhood, there was a man staggering lackadaisically in the middle of the road. He loosely waved to us as we changed lanes to avoid hitting him. He must have been stoned.

Only in Salt Lake.

C# Generic Lists

I remember the many frustrating hours I spent in C and C++ dealing with arrays. I remember the nights hunting down the cause of a bug, only to realize it was the result of exceeding my array bounds. I remember having to redefine and copy arrays when I wanted to change the number of elements in the array, because in C, array length is fixed.

When I learned about linked lists, it got better. Rather than allocating a specific chunk of memory, like a static array did, linked lists are much more flexible because each element simply contains a memory pointer to the next one. This is very flexible, because you can add, remove, or change the nodes in a linked list quite easily.

However, accessing the elements of a linked list is more complicated than accessing an array. In an array, if you wanted to loop through and output all the elements of an array, you could do the following:

for (int i=0; i < sizeof(arrMyArray) / sizeof(int); i++) {
cout << arrMyArray[i] << endl;
}

A linked list is not much more complicated:

for (LinkedList objNode = objMyLinkedList; objNode != null; objNode = objMyLinkedList->Next) {
cout << objMyLinkedList.m_Data << endl;
}

However, the linked list really showed its limitation when trying to access elements randomly. You can do the following with a C array, but not a linked list:

cout << arrMyArray[27];

Thankfully, in C++, the standard template library introduced vectors, which are a kind of dynamic array. The stl::vector saved me a lot of headaches once I learned how to use it.

In C#, you can use what are called generic lists, which are like C++ vectors. As I was programming my GEDCOM importer last night, I really came to appreciate generic lists. They have all the conveniences of the C array and the C++ vector. You can create them dynamically, but you can also access them just like an array. They’re really easy to use, too:

using System.Collections.Generic;

List intNumbers = new List();

intNumbers.Add(3);
intNumbers.Add(7);
intNumbers.Add(8);

for (int i = 0; i < intNumbers.Count; i++) {
Console.WriteLine(intNumbers[i] + “\n”);
}