MI-PSL-9 Flashcards

1
Q
  1. What are the variants of collections and in what packages are they defined?
A

immutable - scala.collection.immutable
mutable - scala.collection.mutable
společné abstraktní kolence - scala.collection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. Draw the graph of inheritance of abstract collections.
A

obrazek

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. What is the collection uniform syntax principle?
A

Jedná se o sjednocení přístupů k prvkům kolekcí přes jejich apply metodu. má-li objekt metodu apply, může se dané slovo při volání vynechat. To samé sjednocení platí pro instancování abstraktních předků, každá abstraktní kolekce má definovaného implicitního konkrétního předka.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. What is the collection uniform return type principle?
A

Všechny návratové hodnoty metod dané kolekce jsou nahrazeny konkrétním typem kolekce. (např. metoda map ve třídě Traversable vrací opět Traversable)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. What is the basic abstract operation defined within Traversable?
A

metoda foreach

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  1. Write an representative of Traversable mapping operations.
A

funkce map - aplikuje funkci f na všechny prvky dané kolekce

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  1. Write an representative of Traversable conversion operations.
A

Převede danou kolekci pomocí metod toXXX na jinou kolekci XXX. Např .toList

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. Write an representative of Traversable size operations.
A

isEmpty, size

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  1. Write an representative of Traversable retrieval operations.
A

head, find

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  1. Write an representative of Traversable subcollection operations.
A

tail, take - veme prvních n prvků, drop - veme prvky (n, traversable.length), filter - vrátí podkolekci splňující podmínku p

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  1. Write an representative of Traversable subdivision operations.
A

splitAt, vrací dvojici rozděleného listu

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. Write an representative of Traversable condition operations.
A

forAll, exists

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  1. Write an representative of Traversable fold operations.
A

foldLeft, reduceLeft, foldRight, reduceRight

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  1. Write an representative of Traversable string operations.
A

mkString - vyrobí string z kolekce

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
  1. What is the basic abstract operation defined within Iterable?
A

abstract def iterator: Iterator[A]
Pomocí této metody jsou implementovány všechny ostatní metody, např.foreach:

def foreach(f: Elem => Unit) {
   val it = iterator
   while (it.hasNext)
     f(it.next())
 }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly