Skip to content

Instantly share code, notes, and snippets.

View cdunn95's full-sized avatar

Cameron D cdunn95

  • Kentucky, USA
  • 11:42 (UTC -04:00)
View GitHub Profile
class Node<T: Equatable>: Equatable {
var value: T
var next: Node<T>? = nil
var prev: Node<T>? = nil
init(value: T) {
self.value = value
}
static func == (lhs: Node<T>, rhs: Node<T>) -> Bool {
@cdunn95
cdunn95 / bubbleSort.swift
Last active August 7, 2019 16:59
Function to sort through an array of integers without using sort() or sorted()
import UIKit
func bubbleSort(_ array: inout [Int]){
for (i,_) in array.enumerated(){
if(i < array.count){
if(i<array.count - 1 && array[i] > array[i+1]){
let temp = array[i+1]
array[i+1] = array[i]
array[i] = temp