Skip to content

Instantly share code, notes, and snippets.

@janselv
janselv / xor_linked_list.cpp
Created July 6, 2016 03:08
Optimized Linked list using XOR operation over pointers.
// this implementation use xor to show the capability over pointers.
// let have 4 nodes A, B, C, D with their respective `next` pointer having
// a reference to the next and previous node(which make the list double linked).
//
// the linked list is built backward(new node become head). This implementation state that.
//
// A.pxor = B.xor(null) which is B.
// B.pxor = A.xor(C) which serve us to find both A & C
// C.pxor = B.xor(D) which serve us to find both B & D
// D.pxor = C.xor(null) which point to the prev node.
@janselv
janselv / UIBezierPathLength.swift
Last active March 8, 2023 08:20
Get total iOS CGPath length as an extension of UIBezierPath written in swift
// The MIT License (MIT)
//
// Copyright (c) 2016 Jansel Valentin
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions: