Unit 5 - Collections, Lists, Maps, Roles of Types Flashcards

1
Q

In principle, there are two different approaches how types and values can be linked:

A
  1. Types intrinsic to values: A type owned by a value. A value has a unique type.
  2. Types as value classifiers: Types are patterns describing a range of values. For each
    classifying type, each value either is or is not conforming to this type. A value can
    conform to several such types.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Values have intrinsic types to facilitate

A

dynamic checking and inspection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Variables, method parameters and method return values (or other value holders) have

A

classifying types so that only certain values can be associated with them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A collection is a

A

composite value that holds a number of component values that can be easily added, removed or changed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Collections can be categorised two criteria

A

as homogeneous vs heterogeneous

and as

fixed-size vs dynamic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Homogeneous, also known as uniform, collections are those

A

where all elements in each collection have the same type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Heterogeneous collections are those

A

where one can mix values of different types in one collection. The values may conform to a classifying type that permits a wide variety of intrinsic types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Examples of fixed-size collections are Java…

A

arrays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Examples of dynamic collections are Java…

A

lists, sets and maps.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Collections are further classified by the kind of abstract structure that holds the components together:

A
  • Sequences
  • Maps
  • Sets
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Collections are further classified by the kind of abstract structure that holds the components together:

Sequences

A

Components form a linear structure that can be used to refer to particular components (eg 101st component), and can be altered by explicit instructions (eg insert an element at the back of a list).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Collections are further classified by the kind of abstract structure that holds the components together:

Maps

A

(also known as dictionaries): Components are stored with unique keys by which they can be identified within the collection. The keys can be of almost any type. When the keys are integers in a range 1 . . . n or 0 . . . (n − 1), the map becomes a sequence.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Collections are further classified by the kind of abstract structure that holds the components together:

Sets

A

No structure visible to programmer, a component is either there or not and no information is accessible about its position in the set.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

N/a

A

Done up to 5.3 Pg4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly