I want to second Leander's suggestion. You could add a field to your map 
like '__true_fields__' : [], and every time a true field is added or 
turns true, you add its name to the array; whenever it turns false, you 
remove it. That's a tiny bit of time to each map update, but gives you 
constant time access to the list of true fields when you need it.

Thomas


> Hi
> 
> I'm not sure if I understand you right, but:
> 
> why don't you save the name of the "true" field while creating the Map?
> As I understand you the map is created in another part of the code / on
> another system, why doesn't this part/system save the information of the
> needed field together with the fields.
> 
> Greetings,
>   Leander
> 
> kanugula wrote:
>> If I have a Map like the following
>> var validationStatusMap = {"field1":false, "field2":false,
>> "field3":false,
>> "field4":true};
>>
>> Is there a way to search true using an index like alogrithem without
>> iterating entire Map?
>>
>> Sometimes I build a big map. I am afraid that each map iteration on each
>> field may hit performance.
>>
>> Thanks.
>> Kanugula.
>>
>>
>> Ralf Nieuwenhuijsen wrote:
>>
>>> Or to keep it more compact:
>>>
>>> rpc.callAsync(myHandler, "calculatePrice",  {
>>>   item:    itemField.getValue(),
>>>   price:
>>> (priceField.getValue()==0)?null:parseFloat(priceField.getValue())
>>> });
>>>
>>> That's all you need. In general, you can build maps like this:
>>>
>>> // creating a new map
>>> var myMap = {};
>>>
>>> // assigning using object notation
>>> myMap.qooxdoo   = "Great";
>>> myMap.javascript = "a powerfull mess";
>>>
>>> // assigning using array notation
>>> myMap["java"] = "a language design failure, marketing success,
>>> poster-child"
>>>
>>> // Let's iterate the map:
>>> for (var k in myMap) {
>>>    alert (k + " is " + myMap[k]);
>>> }
>>>
>>> // Please note that like arrays, when you pass around a map, you pass
>>> around a pointer to the map.
>>>
>>> function simonSays (someMap) {
>>>   for (var key in someMap) {
>>>     someMap[key] = "Simon says: " + someMap[key];
>>>   }
>>> }
>>>
>>> // this _updates_ myMap. It actually changes!
>>> simonSays (myMap);
>>>
>>> // and now call alert on each value in the map
>>> for (var key in myMap) {
>>>   alert( myMap[key] );
>>> }
>>>
>>> // These two statements are equavalent:
>>> var test = new Object();
>>> var test = {};
>>>
>>> Technically, instances of classes are just maps where certains keys
>>> refer to properties, others to functions, etc.
>>>
>>> Also, the trick above to compact it a little, is like an
>>> inline-if-statement
>>> For example, this if-statement:
>>>
>>>     if (x==0) alert("X is Zero"); else alert ("X aint Zero");
>>>
>>> Is equivalent to:
>>>
>>>   alert(  (x==0)? "X is Zero" : "X aint Zero" );
>>>
>>> You use if on the statement level, whereas you can use ? on the
>>> expression level.
>>>
>>> Hope this clears things up a bit for ya!
>>>
>>> Greetings,
>>> Ralf
>>>
>>> -------------------------------------------------------------------------
>>> This SF.net email is sponsored by: Microsoft
>>> Defy all challenges. Microsoft(R) Visual Studio 2008.
>>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>>> _______________________________________________
>>> qooxdoo-devel mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>>>
>>>
>>>
>>
>>
> 
> 
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
> 
> 
> 

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to