1

00:00:01,230  -->  00:00:03,810
OK we're not done with the collection hierarchy.

2

00:00:03,860  -->  00:00:09,710
Now it's time to look at the map hierarchy which is a second inheritance tree in the collections framework

3

00:00:09,900  -->  00:00:10,670
.

4

00:00:11,080  -->  00:00:16,360
Let's begin by looking at the map interface which is the root of the map hierarchy.

5

00:00:17,550  -->  00:00:21,600
We pretty much discuss all of these points during our discussion on hash table.

6

00:00:21,940  -->  00:00:28,500
But let's quickly glanced through them once again not a map store key value pairs and they're useful

7

00:00:28,500  -->  00:00:30,040
for Fras lookups.

8

00:00:30,060  -->  00:00:38,280
Biccies IMAP implementation like a hash map is also referred to as an associate the way maps can not

9

00:00:38,280  -->  00:00:46,920
have duplicate IIS but duplicate values are fine on each key maps to at most one value not some map

10

00:00:46,920  -->  00:00:53,050
implementations allow only one Halki while others do not allow any Nalco at all.

11

00:00:53,220  -->  00:00:57,610
Similarly null values may be allowed or they may be prohibited.

12

00:00:57,970  -->  00:01:03,180
One of the like in the case of collection map also comes with a skeletal implementation abstract map

13

00:01:03,180  -->  00:01:03,840
.

14

00:01:04,130  -->  00:01:10,920
So limitations like hash map extend this particular class just know that it's not just map collection

15

00:01:10,920  -->  00:01:16,710
interfaces which come with skeletally implementations even list certain new interfaces.

16

00:01:16,710  -->  00:01:23,310
Also combat's little implementations under also appropriately named as abstract list abstract set an

17

00:01:23,340  -->  00:01:25,980
abstract Q On all three of them.

18

00:01:25,980  -->  00:01:29,210
Extend that abstract collection.

19

00:01:29,280  -->  00:01:33,130
And here is the declaration of map interface similar to collection and office.

20

00:01:33,210  -->  00:01:39,690
This interface also has methods which are classified and do basic operations on bulk operations collection

21

00:01:39,690  -->  00:01:40,290
interface.

22

00:01:40,290  -->  00:01:45,670
Also how are the operations and we don't how anything of that sort in the map interface.

23

00:01:46,200  -->  00:01:52,080
But map has something called collection view operations and B-ble will soon we'll get them look at Unlike

24

00:01:52,190  -->  00:01:59,670
collection map interface does not extend the interface but the elements can still be detected and we

25

00:01:59,670  -->  00:02:02,510
will see how that can be done.

26

00:02:02,550  -->  00:02:06,120
And here are the methods which follow the basic operations.

27

00:02:06,120  -->  00:02:12,840
Not that here the genetics notation involves the letters K and the V K would stand for key while before

28

00:02:12,940  -->  00:02:18,030
value but don't bother about them as we still did not discuss genetics.

29

00:02:18,030  -->  00:02:21,600
But we know that Canvey can represent anything.

30

00:02:21,600  -->  00:02:21,890
Right.

31

00:02:21,930  -->  00:02:23,650
So that's what genetics is about.

32

00:02:24,000  -->  00:02:28,100
And that anything will be specified at the object creation.

33

00:02:28,440  -->  00:02:34,260
That is when we are creating an instance of a particular map implementation on the first method.

34

00:02:34,260  -->  00:02:35,360
Here is the put method.

35

00:02:35,730  -->  00:02:39,980
It simply asks that given key and value pair into the map.

36

00:02:39,990  -->  00:02:45,340
If there is already a mapping with the same key then the value in that mapping will be overwritten with

37

00:02:45,340  -->  00:02:46,810
the new value.

38

00:02:46,920  -->  00:02:50,440
We already discussed it when covering hash table.

39

00:02:50,580  -->  00:02:53,580
Also the old value will be returned by the matter.

40

00:02:53,580  -->  00:03:00,180
So that's the reason the written type for this method is V where we would be the all value.

41

00:03:00,180  -->  00:03:05,340
But if there was no mapping with that key then the new mapping will be inserted and the null value will

42

00:03:05,340  -->  00:03:06,360
be returned.

43

00:03:06,960  -->  00:03:10,750
But if the map implementation allows it not you.

44

00:03:10,980  -->  00:03:16,350
And there is a matching key with a null value then the null value would be written.

45

00:03:16,350  -->  00:03:21,960
So in this case we cannot tell whether the null value that was written was due to inserting an entirely

46

00:03:21,960  -->  00:03:27,960
new mapping or if it was due to overwriting an existing mapping which had a null value.

47

00:03:28,350  -->  00:03:34,800
But to distinguish these two cases we can invoke the Kandinsky method which returns a true if the input

48

00:03:34,830  -->  00:03:37,550
key is present in the map.

49

00:03:37,560  -->  00:03:39,030
Next is the get method.

50

00:03:39,040  -->  00:03:42,230
Undertreatment the value corresponding by a given key.

51

00:03:42,630  -->  00:03:47,970
If there is no mapping with that key then a null is written the moment that would remove the mapping

52

00:03:47,970  -->  00:03:52,800
for a key under a corresponding value attribute in a null.

53

00:03:52,860  -->  00:04:00,480
If the mapping with a matching key was not for it it is because contains key convinced volume that would

54

00:04:00,480  -->  00:04:07,500
return true if the map contains the specified value size would read and the size of the map is empty

55

00:04:07,500  -->  00:04:07,720
.

56

00:04:07,800  -->  00:04:13,850
Would return true if the size of the map is zero which means that it is empty.

57

00:04:14,000  -->  00:04:16,030
And here are the bulk operations.

58

00:04:16,230  -->  00:04:21,690
Put all method what are all the mappings from the input map into the current map.

59

00:04:21,990  -->  00:04:27,160
So it is similar to the idle method in the collection interface and cleared matter.

60

00:04:27,290  -->  00:04:30,290
Simply remove all the mappings from the map.

61

00:04:30,330  -->  00:04:37,500
Even the collection interface had an identical method and he had a collection view operations you would

62

00:04:37,500  -->  00:04:38,530
use the first method.

63

00:04:38,570  -->  00:04:42,690
He said if you want to view all the keys present in the map.

64

00:04:43,140  -->  00:04:45,330
So this method would it an asset.

65

00:04:45,450  -->  00:04:50,520
If you want to remove one element from the ribbon set you can invoke the return method on the return

66

00:04:50,520  -->  00:04:54,930
set and then you can invoke the remote method on the return to do it.

67

00:04:55,560  -->  00:04:59,170
Alternatively we can also use set methods like Rimmel.

68

00:04:59,220  -->  00:05:02,280
Remove all retain all and clear.

69

00:05:02,590  -->  00:05:09,540
However you cannot work either add or are all methods and you will get an unsupported operation exception

70

00:05:09,560  -->  00:05:09,630
.

71

00:05:09,660  -->  00:05:15,020
If you invoke these matters not that the return set is bad but the origin Alima.

72

00:05:15,300  -->  00:05:20,760
So any changes made in the returns it will be reflected in the original map and vice versa.

73

00:05:21,330  -->  00:05:27,900
Next is a values motard and it will return a collection view of all the values in the map on all the

74

00:05:27,900  -->  00:05:29,310
properties we just discussed.

75

00:05:29,340  -->  00:05:33,450
For the keyset method will also apply for this method.

76

00:05:33,450  -->  00:05:39,780
Note that in case of keyset a set was written whereas in this case a collection is being written.

77

00:05:40,070  -->  00:05:42,540
And can you guess the reason for that.

78

00:05:42,870  -->  00:05:49,600
It is just because Keys are unique and so a set is returned the rest values can contain duplicate and

79

00:05:49,660  -->  00:05:52,190
hence a collection is written.

80

00:05:52,500  -->  00:05:58,620
Not a third method and Chrisette is an interesting method and it can be used for creating them up.

81

00:05:58,680  -->  00:06:05,490
It returns a set view of all the mappings in the map on each mapping is an instance of this interface

82

00:06:05,550  -->  00:06:12,390
called entry which is a nested interface within the map interface so it is not just a process but we

83

00:06:12,390  -->  00:06:19,180
can also how interfaces as an interface is a nice thing about such a nested interface is that it improves

84

00:06:19,180  -->  00:06:20,910
the readability.

85

00:06:20,910  -->  00:06:25,260
No how did been a separate individual interface served as a separate file.

86

00:06:25,530  -->  00:06:31,890
Then it would unnecessarily pollute the namespace even though it is used only by MAP implementations

87

00:06:31,890  -->  00:06:32,510
.

88

00:06:32,670  -->  00:06:34,740
So someone looking at this package might do.

89

00:06:34,740  -->  00:06:41,700
HUME That angry interface is very widely used but now in this case since it is part of the map interface

90

00:06:42,000  -->  00:06:46,550
one would assume that it has something to do with only maps.

91

00:06:46,590  -->  00:06:53,280
Now here each instance of entry corresponds to a mapping in MAP unsoiled stores both he as well as value

92

00:06:54,060  -->  00:06:58,500
on hence pro-white my thoughts like get it and get value.

93

00:06:58,500  -->  00:07:02,510
So any derating them up these methods can be invoked.

94

00:07:02,550  -->  00:07:08,540
There is also the set value method which can be used to update the value in a particular mapping.

95

00:07:08,610  -->  00:07:09,690
Anyway we were tested.

96

00:07:09,720  -->  00:07:10,710
In the next question.

97

00:07:10,740  -->  00:07:17,130
When we look at hash map just know that like the other two collection will return the set that is returned

98

00:07:17,140  -->  00:07:17,210
.

99

00:07:17,310  -->  00:07:23,520
But this particular method is backed by the original map and so all properties with regards to making

100

00:07:23,520  -->  00:07:27,030
any changes will also apply here.

101

00:07:27,120  -->  00:07:33,600
Finally just note that you should be very careful if the keys you use are immutable.

102

00:07:33,600  -->  00:07:37,980
You would want to use keys which are immutable like the strings.

103

00:07:37,980  -->  00:07:44,710
The reason is if you start a mutable object esky and then later you change the state of the object.

104

00:07:44,820  -->  00:07:51,360
Then when you search for that same key the map method and a null value for instance if the map is a

105

00:07:51,360  -->  00:07:56,000
hash map then the hash function might give a different index value.

106

00:07:56,130  -->  00:08:00,230
That is the bucket number after the object stood was changed.

107

00:08:00,450  -->  00:08:04,080
That is the hash function so logic is dependent on the objects state.

108

00:08:04,650  -->  00:08:11,520
Even if it was the same bucket number the subsequent equals method might see that no matching mapping

109

00:08:11,640  -->  00:08:14,590
was found in the corresponding linked list.

110

00:08:14,650  -->  00:08:17,010
Anyway Robert does this out later in the demo.

111

00:08:17,160  -->  00:08:19,920
So let's not worry if it's not really clear to you.

112

00:08:20,460  -->  00:08:23,440
So that's up with the map interface in the next lesson.

113

00:08:23,470  -->  00:08:28,490
They will look at hash map and maybe just all the matters that we have seen in this lesson.

114

00:08:28,610  -->  00:08:31,420
So just state your own and it's going to be an interesting them.

115

00:08:31,560  -->  00:08:31,920
Thank you
