Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 366 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
366
Dung lượng
5,17 MB
Nội dung
[...]... specified element in a collection) COLLECTIONS DESCRIBED Within the two major categories of collections are several subcategories Linear collections can be either direct access collections or sequential access collections, whereas nonlinear collections can be either hierarchical or grouped This section describes each of these collection types Direct Access Collections The most common example of a direct... Framework, the CollectionBase class THE COLLECTIONBASE CLASS The NET Framework library does not include a generic Collection class for storing data, but there is an abstract class you can use to build your own Collection class—CollectionBase The CollectionBase class provides the programmer with the ability to implement a custom Collection class The class implicitly implements two interfaces necessary for... INTRODUCTION TO COLLECTIONS, GENERICS, AND TIMING CLASS Defining a Collection Class The easiest way to define a Collection class in C# is to base the class on an abstract class already found in the System.Collections library—the CollectionBase class This class provides a set of abstract methods you can implement to build your own collection The CollectionBase class provides an underlying data structure,... Dictionary classes that are part of the NET Framework in Chapter 11 Hierarchical Collections Nonlinear collections are broken down into two major groups: hierarchical collections and group collections A hierarchical collection is a group of items divided into levels An item at one level can have successor items located at the next lower level One common hierarchical collection is the tree A tree collection... The final direct access collection type is the struct (also called structures and records in other languages) A struct is a composite data type that holds data that may consist of many different data types For example, an employee P1: IBE 052167015 2c0 1 CUNY656/McMillan 4 Printer: cupusbw 0 521 67015 2 February 17, 2007 21:2 INTRODUCTION TO COLLECTIONS, GENERICS, AND TIMING CLASS record consists of employee’... 17, 2007 21:2 INTRODUCTION TO COLLECTIONS, GENERICS, AND TIMING CLASS COLLECTIONS DEFINED A collection is a structured data type that stores data and provides operations for adding data to the collection, removing data from the collection, updating data in the collection, as well as operations for setting and returning the values of different attributes of the collection Collections can be broken down... at Cambridge, Lauren Cowles and Heather Bergman, for putting up with my many questions, topic changes, and habitual lateness P1: IBE 052167015 2c0 1 CUNY656/McMillan Printer: cupusbw 0 521 67015 2 February 17, 2007 21:2 C HAPTER 1 An Introduction to Collections, Generics, and the Timing Class This book discusses the development and implementation of data structures and algorithms using C# The data structures. .. is a collection of characters that can be accessed based on their index, in the same manner we access the elements of an array Strings are also implemented as class objects in C# The class includes a large set of methods for performing standard operations on strings, such as concatenation, returning substrings, inserting characters, removing characters, and so forth We examine the String class in Chapter... System.Collections; public class Collection : CollectionBase { public void Add(Object item) { InnerList.Add(item); } public void Remove(Object item) { InnerList.Remove(item); } public new void Clear() { InnerList.Clear(); } public new int Count() { return InnerList.Count; } } class chapter1 { P1: IBE 052167015 2c0 1 CUNY656/McMillan 14 Printer: cupusbw 0 521 67015 2 February 17, 2007 21:2 INTRODUCTION... nongeneric data P1: IBE 052167015 2c0 1 CUNY656/McMillan Printer: cupusbw 0 521 67015 2 February 17, 2007 The CollectionBase Class 21:2 17 structure classes, so we will usually limit the discussion of the generic class to how to instantiate an object of that class, since the other methods and their use are no different Timing Tests Because this book takes a practical approach to the analysis of the data structures . programming for industry and education. P1: FCW 0521670152pre CUNY656/McMillan Printer: cupusbw 0 521 67015 2 February 17, 2007 20:59 P1: FCW 0521670152pre CUNY656/McMillan Printer: cupusbw 0.