     }
     
     private func array() -> Array<T> {
-        return lock.around {
-            return self._array.filter {
-                $0.value != nil
-            }.map {
-                $0.value!
+        var result = Array<T>()
+        for item in _array {
+            if let v = item.value {
+                result.append(v)
             }
         }
-
+        return result
     }
 
 }

    }

    public func insert(member: T) {
        lock.around {
            var found = false
            for e in self._array {
                if e.hashValue == member.hashValue {
                    found = true
                    break
                }
            }
            if !found {
                self._array.append(WeakReference(member))
            }
        }
    }

    public func filter(@noescape includeElement: (T) -> Bool) -> WeakSet<T> {


public class WeakSet<T: Hashable where T: AnyObject> {
    private var _array: [WeakReference<T>]
    
    public init() {
        _array = Array()
    }

    public init(_ array: [T]) {
        _array = array.map {
            WeakReference($0)
        }
    }
