Skip to content

Notes and Implementation of different Algorithms and Datastructes

License

Notifications You must be signed in to change notification settings

masters3d/AlgoDataStructures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AlgoDataStructures

Notes and Implementation of different Algorithms and Datastructes

Random Personal Notes

https://gist.github.com/masters3d/9b0fc82de8a349e290bff270cb97bbe8#file-datastructures-md

Algorithms in Swift

https://github.com/apple/swift/blob/3543625a41f6e2d06a1d41ee0082ee3d2001820c/test/Prototypes/Algorithms.swift

Protocols with Associated Types

"A protocol with associated type is just a fancy term to a protocol that has generics in it". https://www.natashatherobot.com/swift-what-are-protocols-with-associated-types/

Protocols with Self requirements can only be used as a Generic Constrain. https://stackoverflow.com/questions/24926310/what-does-protocol-can-only-be-used-as-a-generic-constraint-because-it-has This means that you can only make sure that something conforms to the protocol but you are not able to speicy the types of protocols that something should conform to, the difference is subtly and it only comes up in syntax, usually this required saying where T:SomeProto instead of just saying T:SomeProto. The self requirements throws a rench in the gears.

Sorting

Introsort or introspective sort is a hybrid sorting algorithm that provides both fast average performance and (asymptotically) optimal worst-case performance
Swift 4 uses Introsort
https://en.wikipedia.org/wiki/Introsort

Stable Sort

Timsort is a hybrid stable sorting algorithm, derived from merge sort and insertion sort https://en.wikipedia.org/wiki/Timsort

Block sort, or block merge sort, is a sorting algorithm combining at least two merge operations with an insertion sort to arrive at O(n log n) in-place stable sorting.
https://en.wikipedia.org/wiki/Block_sort

Existential Notes:

In swift this can be refered as Protocol as Types. Related

Chapter 24 of Types and Programming Languages by Piece
Polymorphism, Objects and Abstract Types link

I've been sort of confused about what an existential is. In Swift, this comes up a lot when talking about Generics. My understanding is that these pretty much things that describe types but they are not necessarily types themselves? So an interface/protocol is an existential in swift.

Other definitions seem to relate the idea of Existential to some form of generics. It would seem that in order for a protocol/interface/trait to be an existential it needs also have generics involved.

While a single protocol/interface/trail can be considered an existential, it is not until you combine multiple existential that you can see the power of this feature. Another key point of an existential seems that it is supposed to hide the actual concrete type. This comes up a lot with type erasure containers.

About

Notes and Implementation of different Algorithms and Datastructes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages