Question: I understand from my recent use of PHP-PDO over the last few months that you can do a PREPARE statement and then run the query. In fact I can see the usefulness of this if I'm going to either SELECT on a complex join, varying the where conditions, a repeated number of times.

Or, similarly, if I was wanting to insert multiple records.

However, if I know I only want to run a statement once, shouldn't I just EXECUTE the query? I'm basically querying the database twice.

Answer: 
Always in such a case the critical factor is how to compare objects and what types of objects go into the Set. Using a Swift Dictionary, where the Set objects are the dictionary keys, could be a problem based on the restrictions on the key type (String, Int, Double, Bool, valueless Enumerations or hashable).

**If you can define a hash function** on your object type then you can use a Dictionary. **If the objects are orderable**, then you could define a Tree. **If the objects are only comparable with `==`** then you'll need to iterate over the set elements to detect a preexisting object.

```
// When T is only Equatable
class Set<T: Equatable> {
  var items = Array<T>()

  func hasItem (that: T) {
   // No builtin Array method of hasItem... 
   //   because comparison is undefined in builtin Array   
   for this: T in items {
     if (this == that) {
       return true
     }
   }
   return false
  }

  func insert (that: T) {
    if (!hasItem (that))
      items.append (that)
  }
}

```

The above is an example of building a Swift `Set`; the example used objects that are only `Equatable` - which, while a common case, doesn't necessarily lead to an efficient `Set` implementations (O(N) search complexity - the above is an example).
Special case for classes derived from NSObject

given that default Equitable (& Hashable) conformance in NSObject is basically trash you'd better make sure you provide a proper 

```
static func == (lhs: YourClassDerivedFromNSObject, rhs: YourClassDerivedFromNSObject) -> Bool {

```

implementation lest you want plucking the duplicates inserted into
Set