Buenas de nuevo !!
Necesitas obtener la posicion donde tienes el string en la matriz de primer
nivel o tambien en la de 2º? Osea, necesitas obtener un array de resultados
tipo [0,4....] o bien [[0,1],[2,0]...] ?
Asi en principio veo que buscas primero si tienes el string en todo el array
con match(), y si lo tienes, luego buscas donde está recorriendo la matriz
completa y le pasas el match() de nuevo pero a el elemento[i] del array
"joineado" con lo que no sabes en q posicion, 0 o 1 está dentro de ese
elemento[i], por eso te preguntaba si no te interesaba mejor saber
"exactamente" donde está.
De todos modos, como el array es muy pequeño, no creo que te coma muchos
recursos, aunque se ha comentado que los S60 no dan para mucho, no creo que
se atasquen con una cosa asi no ?
El 13/9/06 22:02, "Ale Muñoz" <[EMAIL PROTECTED]> escribió:
>
> On 13/09/2006, at 19:52, Fede Rivas wrote:
>
>> Buenas Ale !!
>> Imagino que la estas recorriendo con un for, podrias almacenar el "i"
>> facilmente en un array temporal y luego lo tiras con el return del
>> metodo (
>> se me ocurre asi a bote pronto ), devolviendote justo un array con las
>> posiciones exactas donde tienes los strings.
>
> Es justo lo que estoy haciendo :D
>
>> Posteanos el code si quieres y vemos como tunearlo.
>
> A verrrrrr...
>
> Este es el código de la clase (en AS2 garrapatero : ), pero lo que
> me interesa está en el método 'update':
>
> class Searcher implements Observer extends Observable {
> var fields:Array;
> var results:Array;
> var cache;
> function Searcher(fields:Array){
> this.fields = fields;
> clearResults();
> this.cache = fields.join(",").toUpperCase();
> }
> function toString(){
> return "Searcher Object";
> }
> function update(w:Observable,o:Object){
> var what = o.txt.toUpperCase();
> trace( "Will search for " + what);
> clearResults();
> // First check if it is there...
> var matched = this.match(what,this.cache);
> if(matched.status){
> trace("The string is there, beginning at " + matched.position);
> // ...then search for the item that contains it...
> for(var i=0; i < this.fields.length ; i++){
> var current_item = this.fields[i].join(",").toUpperCase();
> trace("Searching for " + what + " in " + current_item);
> if(this.match(what,current_item).status){
> this.addResult(i);
> }
> }
> } else {
> trace("The string was not found...");
> }
> setChanged();
> notifyObservers(this.results);
> }
> function match(what,where){
> var isThere:Number = where.indexOf(what);
> if(isThere == -1){
> return {status: false, position: isThere};
> } else {
> return {status: true, position: isThere};
> }
> }
> function addResult(r){
> trace("Adding result " + r + " to list");
> this.results.push(r);
> }
> function clearResults(){
> this.results = [];
> }
> function getData(row:Number){
> return fields[row];
> }
> }
>
> Todavía no está tuneada, pero me interesa más saber si hay
> alternativas más rápidas al clásico 'for' (o alguna idea feliz, como
> la de convertir el Array en un String, cachearlo, y hacer búsquedas
> con indexOf, que es bastante más rápido que recorrer el Array...)
>
>
>> ¿ Es mu tocho el array en el que buscas ?
>
>
> Es una mierdecilla de Array (una matriz de 2x12 o así). El problema
> es que se ejecuta en una plataforma (Symbian S60) que no es que
> vaya muy sobrada de potencia, precisamente :D
>
> Gracias por los comentarios!
>
>
>
> Ale Muñoz
> [EMAIL PROTECTED]
>
> blog » http://sofanaranja.com
>
>
>
> -----------------------------------------------------
> ASNativos
> www.5dms.com
> subscripciones/desubscripciones
> http://asnativos.5dms.com
> -----------------------------------------------------
>
-----------------------------------------------------
ASNativos
www.5dms.com
subscripciones/desubscripciones
http://asnativos.5dms.com
-----------------------------------------------------