Presentation is loading. Please wait.

Presentation is loading. Please wait.

Recap Visual Perception and Data Visualization Types of Information Display Examples of Diagrams used for Data Display Planning Requirement for Data Visualization.

Similar presentations


Presentation on theme: "Recap Visual Perception and Data Visualization Types of Information Display Examples of Diagrams used for Data Display Planning Requirement for Data Visualization."— Presentation transcript:

1

2 Recap Visual Perception and Data Visualization Types of Information Display Examples of Diagrams used for Data Display Planning Requirement for Data Visualization Benefits of Data Visualization

3

4 Pointers A pointer is an object that can be used to access another object A pointer provides indirect access rather than direct access to an object People use pointers in real-life situations all the time In C++ a pointer is an object that stores an address (i.e., a location in memory) where other data are stored An address is expected to be an integer, so a pointer object can usually be represented internally as an (unsigned) int.

5 Arrays and Structures An aggregate is a collection of objects stored in one unit The array is the basic mechanism for storing a collection of identically-typed objects A different type of aggregate type is the structure, which stores a collection of objects that need not be of the same type Abstract Example: consider the layout of an apartment building. Each floor might have a one-bedroom unit, a two-bedroom unit, a three-bedroom unit, and a laundry room. Thus each floor is stored as a structure, and the building is an array of floors.

6 Types of Arrays In C++ arrays are declared in two basic ways Primitive method to use the built-in array Alternative method vector Syntax for both methods is more or less the same Vector is much easier and slightly safer to use than the primitive array and is preferred for most applications Vectors behave as First Class Type Primitive array behave as Second Class Type

7 First Class versus Second Class First-class objects can be manipulated in all the “usual ways” without special cases and exceptions, whereas second-class objects can be manipulated in only certain restricted ways Usual ways include things like copying an array stores a collection of objects So, expect a copy of an array to copy the entire collection; this is not the case for the primitive array

8 Continued…. when allocated arrays are no longer needed (for instance the function in which they are declared returns), then the memory that these arrays consumes is automatically reclaimed This is true sometimes and false at other times for arrays

9 Continued…. The primitive string may be considered even lower than a second-class object because it suffers all the second-class behavior of arrays its comparison operators do not do what we would normally expect them to do and thus have to be handled as a special case

10 Vectors and Strings The vector and string classes in the Standard Library treat arrays and strings as first-class objects A vector knows how large it is Two string objects can be compared with ==, <, and so on Both vector and string can be copied with = Except in special cases avoid using build in array and strings

11 Continued…. The string is a class, or the library type used for first-class strings The vector is a class template, or the library type used for first- class arrays Using a library routine does not require knowing anything about its underlying implementation However, for second class objects you may need to know that how their counterparts are manipulated both string and vector are implemented by providing an interface that hides the second-class behavior of the built-in types

12 Vectors

13 Using the Vectors To use standard vector, include a library header file as #include An array must be declared before it is used in an expression and initialized before its value is used A vector is declared by giving it a name, in accordance with the usual identifier rules, and by telling the compiler what type the elements are A size can also be provided; if it is not, the size is zero, but vector will need to be resized later

14 Continued…. In an array object can be accessed by using array indexing operator [ ] In C++, arrays are always indexed starting at zero vector a(3); // 3 int objects: a[0], a[1], and a[2] The size of the vector can always be obtained with the size function For the preceding code fragment example, a. size ( ) returns 3 The dot operator is used to call the vector's size function

15 Continued…. The size of a vector can always be changed by calling resize an alternative declaration for the vector a could have been vector a; / / 0 int objects a.resize( 3 ) ; / / 3 int objects: a[0], a[l], and a[2] Simple example of array in next slide

16


Download ppt "Recap Visual Perception and Data Visualization Types of Information Display Examples of Diagrams used for Data Display Planning Requirement for Data Visualization."

Similar presentations


Ads by Google