     
     deinit
     {
-        NSLog("Ups <");
-    }
-    
-}
-
-class PQueue<T where T : Priority> : Queue<T>
+    }
+    
+}
+
+class PQueue<T where T: AnyObject, T:Priority> : Queue<T>
 {
     var maximum:Int? {
         get {

    }
}

func ==<T>(lhs: Element<T>, rhs: Element<T>) -> Bool
{
    return ObjectIdentifier(lhs) == ObjectIdentifier(rhs);
}

postfix func ++<T>(inout e: Element<T>?) -> Element<T>?

        tail = Element<T>(item: nil, previous: tail);
    }
    
    func remove(item:T)
    {
        weak var current = head;
        while( !(current === tail) && !(current == item) )
        {
            current++;
        }
        
        if(current != nil)
        {
            remove(current!);
        }
    }
    
    func remove(index: Int)
    {
        weak var current = head;
        var idx = index;
        
        while ( !(current === tail) && (idx > 0) ){
            idx -= 1;
            current++;
        }
        
        if(current != nil)
        {
            remove(current!);
        }
    }
    
    func remove(element: Element<T>) -> Element<T>?
    {
        if(head === tail)
        {
            return nil;
        }
        
        let fixHead = element === head;
        var previous = element.prev;
        var next = element.next;
        
        previous?.next = next;
        next?.prev = previous;
        
        element.next = nil;
        element.prev = nil;
        element.item = nil;
        
        if(fixHead)
        {
            head = next;
        }
        
        return previous;
    }

    func each(callback:(Int,T?) -> Void)
    {
        weak var current = head;
        var idx = 0;
        while ( !(current === tail) )
        {
            weak var next = current?.next;
            let item:T? = current?.item;
            callback(idx++,item);
            current = next;
        }
    }
    
