Implementing a Set in Go - Go Data Structures

  Рет қаралды 4,185

TutorialEdge

TutorialEdge

3 жыл бұрын

👨‍💻 For the price of $7.99 every month, sign up and gain access to a growing list of premium courses on my site - tutorialedge.net/pricing/
Welcome Gophers, this video is part of my Go Data Structures course in which we learn how we can implement out own versions of standard data structures in Go.
The original version of this video can be found here - tutorialedge.net/courses/go-d...
You can find the full courses here - tutorialedge.net/courses/go-d...
✅ Subscribe and hit that 🔔 to get notified for all the latest tutorials!
🤓 / elliot_f
‎💻 tutorialedge.net
🎥 Recording Setup
Microphone - amzn.to/3hvASys
Mic Boom - amzn.to/3o0cW8Q
Mouse - amzn.to/2WZMoZs
Monitor 1 - amzn.to/38IUlYy
Monitor 2 - amzn.to/3rBTZf7
Mount - amzn.to/3o3185V
USB-C Hub - amzn.to/3o2xRbw

Пікірлер: 15
@a_maxed_out_handle_of_30_chars
@a_maxed_out_handle_of_30_chars Жыл бұрын
thank you
@rockand7cod
@rockand7cod Жыл бұрын
Excellent tutorial. I was wondering if you can use generics that way I can have a set that can hold ints without having to rewrite the entire thing using int instead of string
@AG-zc2jt
@AG-zc2jt 2 ай бұрын
Why do we use structure{}{}
@dognikD
@dognikD 3 жыл бұрын
Good tutorial, but in method Add maybe refactor to func (s *Set) Add(elems …string) ?
@TheSmelzo
@TheSmelzo 3 жыл бұрын
Thanks! Yeah, that is a good refactor to allow adding multiple elements at once!
@padawanalberto
@padawanalberto 2 жыл бұрын
Nice tutorial. I have a question. Why the NewSet is returing a pointer and not the variable defined inside the function?
@a_maxed_out_handle_of_30_chars
@a_maxed_out_handle_of_30_chars Жыл бұрын
the methods defined on set are pointer receiver i.e add, delete, list are pointer receivers
@PavelAShvedov
@PavelAShvedov 3 жыл бұрын
I'd like to change existence check in Delete method to s.Contains call,
@Tutorialedge
@Tutorialedge 3 жыл бұрын
That works! I just chose to go through the more verbose approach to concentrate more on the underlying logic but you can absolutely mix this up and use the Contains method.
@DanielG_A
@DanielG_A 3 жыл бұрын
I have a question, why use map[string]struct{} and not map[string]interface{} ? , nice video though :)
@Tutorialedge
@Tutorialedge 3 жыл бұрын
Hi Daniel, thanks for the question! The reason I have opted for an empty struct is due to memory usage. For a set implementation we only want to check if the value is present as a key, we don’t necessarily care about the value assigned to that key in the map. An empty struct uses 0 bytes whereas an empty interface uses 8 bytes.
@DanielG_A
@DanielG_A 3 жыл бұрын
@@Tutorialedge Thanks for your answer ! it makes sense! Looking forward for more videos like these :)
@artemsukharenko4877
@artemsukharenko4877 3 жыл бұрын
Set is not only unique elements - where intersect and other important methods? We wont TRUE set! :D
Defer in Go - Beginner's Guide to Go
12:02
TutorialEdge
Рет қаралды 4,1 М.
Understanding Contexts in Go in 5(-ish?) Minutes
15:14
TutorialEdge
Рет қаралды 60 М.
Playing hide and seek with my dog 🐶
00:25
Zach King
Рет қаралды 35 МЛН
Summer shower by Secret Vlog
00:17
Secret Vlog
Рет қаралды 13 МЛН
Опасность фирменной зарядки Apple
00:57
SuperCrastan
Рет қаралды 11 МЛН
50 YouTubers Fight For $1,000,000
41:27
MrBeast
Рет қаралды 210 МЛН
Golang Linked List - Golang Data Structures
40:56
Golang Dojo
Рет қаралды 14 М.
WorkerPools in Go Tutorial
11:38
TutorialEdge
Рет қаралды 20 М.
How I Structure New Projects In Golang
21:32
Anthony GG
Рет қаралды 55 М.
Methods in Go - Beginner's Guide to Go Course
8:34
TutorialEdge
Рет қаралды 2,8 М.
Concurrency in Go
18:40
Jake Wright
Рет қаралды 611 М.
Understanding and implementing a Hash Table (in C)
24:54
Jacob Sorber
Рет қаралды 346 М.
Golang Package Structure Explained in 7 Minutes
7:07
Golang Dojo
Рет қаралды 36 М.
Rust Data Modelling Without Classes
11:25
No Boilerplate
Рет қаралды 167 М.
Golang Arrays & Slices (Interview Question)
8:47
Esoteric Tech
Рет қаралды 3,5 М.
Don't throw exceptions in C#. Do this instead
18:13
Nick Chapsas
Рет қаралды 255 М.
Playing hide and seek with my dog 🐶
00:25
Zach King
Рет қаралды 35 МЛН