Skip to content

Instantly share code, notes, and snippets.

View loromits's full-sized avatar

Anton Kovtun loromits

  • Mykolayiv, Ukraine
View GitHub Profile
@loromits
loromits / DoublyLinkedList.swift
Last active November 28, 2024 23:34
Doubly Linked List implementation in Swift
struct DoublyLinkedList<Element> {
class Node {
var value: Element
weak var next: Node?
var previous: Node?
init(_ value: Element, next: Node?, previous: Node?) {
(self.value, self.next, self.previous) = (value, next, previous)
next?.previous = self
previous?.next = self
@loromits
loromits / Stack.swift
Last active September 11, 2017 10:06
Simple Stack data structure implementation in Swift
struct Stack<Element> {
fileprivate class Node {
let value: Element
var previousNode: Node?
init(_ value: Element, previousNode: Node?) {
self.value = value
self.previousNode = previousNode
}
}