Shortest way to check for differences in a Boolean dictionary

So, I am sure you guys can lead me on this problem…

What are your suggestions to check for differences in a dictionary of Booleans…

I need to know if

  1. All the items are true
  2. All the items are false
  3. The items have different values

I guess I have to iterate, right ? And then compare the last value with the current value ? Am I in the right direction ?
Ideas ?

If the boolean is stored as 1 or 0 rather than true / false

All TRUE ?
select sum(thefield) = count(thefield) from table

All FALSE :
select sum(thefield) = 0 from table

Different values:

select  sum(thefield) <> count(thefield)  from table

@Jeff Tullin - what’s that got to do with Dictionaries?

Iterating is one way.

Another approach is to keep track of the count as you manipulate the dictionary. This can be preferable in situations where the dictionary is continually being modified, and you regularly need an update summary result without having to loop all values each time.

Make a subclass of dictionary, with the following methods:

property true_count as integer

sub Value(key as Variant, _value as Variant)

//assumes _value will only ever be a boolean; extra checks may be
//needed if this is not the case

if me.hasKey(key) then
  if me.value(key)<>_value then
    if _value then
      true_count=true_count+1
      
    else
      true_count=true_count-1
    end if
  end if
  
elseif _value then
  true_count=true_count+1
end if

super.value(key)=_value
end sub

function all_items_are_true() as boolean
  return count=true_count
end function

function all_items_are_false() as boolean
  return true_count=0
end function

@Greg O’Lone

Nothing.
The original post (before it was amended by the OP) said recordsets/dictionaries.

cool… thanks for the good ideas !