110 likes | 258 Views
CIS 3260. Week 7 (Data Structures). Terms to Know. FIFO LIFO Generics Hashtable Dictionary<T>. Linked list ArrayList (and List<T>) Linked List Queue (and Queue<T> ) Stack (and Stack<T> ) Tree. What's a major problem with arrays?.
E N D
CIS 3260 • Week 7 (Data Structures)
Terms to Know FIFO LIFO Generics Hashtable Dictionary<T> • Linked list • ArrayList • (and List<T>) • Linked List • Queue (and Queue<T>) • Stack (and Stack<T>) • Tree
What's a major problem with arrays? • We have to know its size before we can declare it.
The Linked List null
The Stack Last In, First Out The Queue First In, First Out
But ... what can go in these classes? • What if we want type-safety? "Generics"
using System;using System.Collections;public class SamplesArrayList {public static void Main() { // Creates and initializes a new ArrayList. ArrayList myAL = new ArrayList(); myAL.Add("Hello"); myAL.Add("World"); myAL.Add("!"); // Displays the properties and values of the ArrayList. Console.WriteLine( " Count: {0}", myAL.Count ); Console.WriteLine( " Capacity: {0}", myAL.Capacity ); Console.Write( " Values:" ); PrintValues( myAL ); }public static void PrintValues( ArrayList myList ) {foreach ( Object obj in myList ) Console.Write( " {0}", obj ); }}
null ... [ ]