 //  Created by JUSTIN M FISCHER on 12/1/14.
 //  Copyright (c) 2013 Justin M Fischer. All rights reserved.
 //
-
 import Foundation
 
 class Node<K, V> {

            if let node = self.hashtable[key] {
                node.value = value
                
                self.queue.remove(node)
                self.queue.addToHead(node)
            } else {
                let node = Node(key: key, value: value)
                
                if self.length < capacity {
                    self.queue.addToHead(node)
                    self.hashtable[key] = node
                    
                    self.length++
                } else {
                    hashtable.removeValueForKey(self.queue.tail!.key)
                    self.queue.tail = self.queue.tail?.previous
                    
                    if let node = self.queue.tail {
                        node.next = nil
                    }
                    
                    self.queue.addToHead(node)
                    self.hashtable[key] = node
                }
            }
        }
    }
        
    var description : String {
        return "SwiftlyLRU Cache(\(self.length)) \n" + self.queue.display()
    }

    private var hashtable: [K : Node<K, V>]
    
    /**
     Least Recently Used "LRU" Cache, capacity is the number of elements to keep in the Cache.
     */
    init(capacity: Int) {
        self.capacity = capacity
        
