Just want to throw it out there that I don't think any of us watching just assume that you're lying about something until you prove otherwise. Thanks for the videos! :)
@tomdraper35884 жыл бұрын
These tutorials are fantastic, thank you so much
@lucianodesa14 жыл бұрын
Great videos! Just a small correction. The access time of any element within an array is also constant time O(1), in fact, being very simplistic, the underlying structure of a map is actually an array where its indexes are calculated using a hash algorithm and the "order" of the elements in a map is the ordering of its indexes generated by the hash algorithm.
@AXYGaming4 жыл бұрын
Yes, infact maps are slower because of the hashing algorithm
@tylermorton20574 жыл бұрын
+1 to this explanation :) To add to this, the way it was explained to me in college... Accessing an array element is O(1) because the entire array is stored in the same contiguous block of memory. If we know the memory address of the first element and we know the size of the array's element type, we can simply access the memory location of any index by multiplying that index by the data size and adding that value to the first element's memory address. For example, imagine we have an int array that contains 5 elements and the memory address of the pointer to the first element is at address 64. The size of each element in the array is 4 bytes (32 bit int). So to access the 4th element (index 3) in the array, we take "address + ( size * index)"... or 64 + ( 4 * 3 ) = 76. The 4th element's memory address is 76. This is an oversimplification and not exactly how memory addresses are stored and handled under the hood, but I hope it helps get the point across. Again, this is only able to be done because the array's memory is one contiguous block. This also explains why we must create new arrays when we want to add elements-- the memory block needs to be moved somewhere where there is space to facilitate the new elements being added in order to remain contiguous.
@mukhammadaminabdullaev47683 жыл бұрын
@@tylermorton2057 Good Explanation Bro!
@FeedFall84 жыл бұрын
Tim is best
@clyn465 Жыл бұрын
Tim is always great, thanks dude
@simonmarchant55203 жыл бұрын
Clear and concise, good vid
@rahamoosavi43683 сағат бұрын
Thank you sooooo much Keep going🫶🏻
@MaximRovinsky4 жыл бұрын
Super. Thank you!
@malu_1Ай бұрын
nice vid !
@2cmarx2 жыл бұрын
Great video. Really enjoying your videos
@FPChris2 жыл бұрын
Great videos. How do you loop through a map? Also the declaration seems unnecessarily long. Why do they require repeating map[string]int twice?
@Sergey_Latyshev4 жыл бұрын
3:02 - it seems the words are in alphabetical order.
@erik.andri12 Жыл бұрын
Is it the same as python dictionary. But ia there any special function to call if the key exists for if else statement, like in python will be: if apple in mp. How to write this kind if else statement in GoLang?
@marupakanagaharshita63234 жыл бұрын
It would be really helpful if you teach how to deal with nested data types in maps.
@mesayshemsu21342 жыл бұрын
Nice Tutorial! Can you make tutorial for MapReduce?
@bedroomdevs37432 жыл бұрын
did mine like so; // iterating with the range keyword numbers := []int{1,2,3,4,5,6,1,4, 7, 7} // print out duplicates in the above array for i, item := range numbers { set := numbers[i+1:] for _, element := range set { if item == element { fmt.Println(element) } } }
@jhonatanmaia56523 жыл бұрын
Fantastic video
@CSSuccessGamer4 жыл бұрын
nice video! what is golang useful for? I have already dedicated my life to python and dart and nothing else.
@RandomShowerThoughts4 жыл бұрын
i started with Python, but Go is exceptional for rest servers, microservices, working with databases, caches, gRPC. I work at a company and we've made the transition to Go from python and we use it for our backend. It does authentication, rate limiting, routing, etc. We also use it for alot of dns stuff
@Jeppelelle4 жыл бұрын
What if one would want a mixed content map with both [string]string & [string]int in the same map for something like (pseudocode) var product { "product_id": 2934, "product_description": "Blekrj ekjreroe" } Is that possible?
@kilianvounckx99044 жыл бұрын
There are 2 options I can think of. The first is using structs. Structs are the closed analog golang has to classes and objects if you are coming from an OOP language like python. You could make a struct which contains an integer and a string: type product struct { id int description string } This creates a new type named product which you can later use like any other type (int, string, float654, ...): p1 := product {id: 2934, description: "Blekrj ekjreroe"} The second method is using interface{}. When you use interface{} it basically means you can use any type you want. If you use a map with strings as keys and interfaces as values, you can get what you want: product := make(map[string]interface{}) product["id"] = 2934 product["description"] = "Blekrj ekjreroe" There are probably other solutions but these I can think of. Which you use will depend on your use case. I'm sure there will be more in depth tutorials about structs and interfaces in this series. They are pretty common in golang.
@GerardJonesYT3 жыл бұрын
is possible with var p map[string]interface{} where interface{} could be any type
@abhishek79694 жыл бұрын
👍
@eyadali36374 жыл бұрын
What's the name of the vscode theme?
@din-paz4 жыл бұрын
how to iterate all key and values in the map that your missing...
@senzanome83792 жыл бұрын
Geat video
@vasusubbannavar57894 жыл бұрын
Is Go an object oriented programming language?
@RandomShowerThoughts4 жыл бұрын
somewhat, it has structs which can be thought of like classes. But there is no inheritance. That being said there are interfaces which you can use for polymorphism (duck typing) which is pretty awesome. Once a struct satisfies an interface with a set of functions we can use similar structs in functions. Obviously not the most in depth but wanted to chime in
@SSSNIPD4 жыл бұрын
Is this the same as a python dictionary?
@marcuslee6784 жыл бұрын
Ya, it's somewhat similar
@ashafloki3 жыл бұрын
Noice
@buddybob55024 жыл бұрын
Guess what I am not first
@hououinkyouma53723 жыл бұрын
So basically it's a hash map
@unperrier2 жыл бұрын
Your "low-level" details are confusing because you mix two concepts, key/index and value: - You say that maps are fast because we can randomly access any data - And that arrays are slow because we may need to go through a bunch of data to get he one we want. The confusion is that you access maps by using a key, which fast (although not the fastest) and you access arrays using the value, not the index. But when using the index, arrays are much faster than maps because they're instantly and randomly accessible, it's just a simple arithmetic operation, whereas maps need to calculate a hash, and often handle hash collisions using a linked list which then need to be browsed element-by-element to find the right element. What you were supposed to say instead is that a map is much faster than a SORTED array.