Hi
Yes I thought about building a AVL binary tree and attaching it to the
store but I am not sure I need to as most of the data will be sorted on
the server as part of an SQL statement so I only needed a method to
lookup keys from a Data Dictionary where some of the widget properties
are stored so the application can be customized by the client.
I am interested to know if my method of creating the Search() function
using the "new Function" syntax is the best way to accomplish a
generalized evaluation technique.
Simon
On 04/01/2012 1:34 AM, John Spackman wrote:
> Hi,
>
> If you've only got laTable as a flat array then a bisect search like that
> is about as good as it gets; if you're going to do a lot of lookups for
> particular sets of keys you could consider building an index, e.g.
>
> var lmIndex = {};
> for (var i = 0; i< laTable.length; i++)
> lmIndex[Search(laTable[i])] = laTable[i];
>
> var match = lmIndex[tmSearch.key];
>
>
> You'd have to cache lmIndex for each set of keys and rebuild the index if
> the model changes.
>
> John
>
> On 04/01/2012 03:47, "Simon White"<[email protected]> wrote:
>
>> Hi
>>
>> I would appreciate feedback on the following search function. I would
>> like to know if there are more efficient ways of accomplishing my goal
>> of finding items in a store the quickest way possible. It will be used
>> on ordered JSON stores as follows:
>>
>> myStore.dcSeek({key: ["TABLE","ATYPE","NAME"],value:
>> "VMMASTER.DBFFCARD"});
>>
>> The store in this case is order by three fields TABLE, ATYPE and NAME
>> and I want to find the item whose TABLE == "VMMASTER.DBF" and ATYPE
>> =="F" and NAME == "CARD"
>>
>> I tested it on a store with 2410 items and it finds the correct value in
>> 10 tries and found a match at laTable[2336].
>>
>> dcSeek : function(tmSearch) {
>> // get the model's data array
>> var laTable = this.getModel().get(this.getTable()).toArray();
>> var lcTxt = "";
>> var lcPlus = "";
>>
>> // build the text for the search function body
>>
>> for (i=0; i<tmSearch.key.length; i++){
>> lcTxt = lcTxt+lcPlus+"mRecord.get('"+tmSearch.key[i]+"')"
>> lcPlus="+"
>> }
>>
>> // create a search function to retrieve the required array items
>>
>> var Search = new Function("mRecord","return "+lcTxt)
>> var lnMin = 0;
>> var lnMax = laTable.length;
>> var lcKey = "";
>> while (lnMin<= lnMax)
>> {
>> lnMid = parseInt((lnMin+lnMax)/2);
>> this.mRecord = laTable[lnMid];
>> lcKey = Search(this.mRecord).toUpperCase();
>> if (lcKey> tmSearch.value){
>> lnMax = lnMid -1;
>> } else if (lcKey< tmSearch.value){
>> lnMin = lnMid +1;
>> } else {
>> return true;
>> }
>> }
>> this.mRecord = null;
>> return false
>> }
>>
>>
>>
>>
>> On 03/01/2012 3:27 PM, Simon White wrote:
>>> Hi
>>>
>>> This maybe more of a javascript question than QooxDoo and is due to my
>>> as yet inadequate knowledge of the inner workings of Javascript.
>>>
>>> I have an array in the form of:
>>>
>>> Menu = [{id: "TEST1",color: "blue",name: "myBlue"},
>>> {id: "TEST36",color: "grey",name: "myGrey"},
>>> {id: "TEST2",color: "red",name: "myRed"},
>>> {id: "TEST34",color: "grey",name: "anotherGrey"}]
>>>
>>> In my case the array has more than 1000 elements and I want to find the
>>> item containing the color == "grey" and the name =="myGrey". Is there a
>>> means to use the indexOf method or do I need to just create my own
>>> function for searching?
>>>
>>> I was trying to use a builtin methods assuming it would be faster than
>>> my custom code.
>>>
>>> Thanks
>>> Simon
>>>
>>>
>>>
>>> -------------------------------------------------------------------------
>>> -----
>>> Write once. Port to many.
>>> Get the SDK and tools to simplify cross-platform app development. Create
>>> new or port existing apps to sell to consumers worldwide. Explore the
>>> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
>>> http://p.sf.net/sfu/intel-appdev
>>
>>
>>
>> --------------------------------------------------------------------------
>> ----
>> Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
>> infrastructure or vast IT resources to deliver seamless, secure access to
>> virtual desktops. With this all-in-one solution, easily deploy virtual
>> desktops for less than the cost of PCs and save 60% on VDI infrastructure
>> costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
>> _______________________________________________
>> qooxdoo-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>
>
>
> ------------------------------------------------------------------------------
> Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
> infrastructure or vast IT resources to deliver seamless, secure access to
> virtual desktops. With this all-in-one solution, easily deploy virtual
> desktops for less than the cost of PCs and save 60% on VDI infrastructure
> costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel