On Nov 25, 2:09 pm, Martin DeMello <martindeme...@gmail.com> wrote: > On Thu, Nov 26, 2009 at 12:31 AM, Jonathan Smith > > <jonathansmith...@gmail.com> wrote: > > > I think a better way to do this is to not use a regex at all. > > Canonically I think this sort of thing is (would be?) implemented by > > constructing a 'sequence' of strings, (first filtered based on > > potential word length) and recursively filtering based on 'character > > at position x' in the string, as characters are entered... the > > resulting seqs could be memoized. > > Isn't 'character at position x' an expensive test too? I have a > feeling tries will do better here - I actually started working on a > trie-based implementation, then decided to see if it really was the > linear regexp scan that was slowing things down, and when it looked > like it wasn't, I dropped the idea. I'll complete that and see how it > looks. > > > Then, you could type a letter and quickly update the options based on > > the new character at that position (by simply filtering the stored > > sequence one more time). When you delete a letter, you run it and > > receive the memoized result from earlier. > > Nice idea. > > > To display you would want to use 'into-array' and your 'setListData' > > function, because you seem to have a homogeneous collection of > > strings; while to-array makes you an array of objects, into-array will > > return an array of strings (It might help, I'm really not sure). > > Another good idea. I forgot strings weren't Objects in java. > > martin
Shouldn't charAt be approximately equivalent to an array dereference? I wouldn't expect it to be terribly expensive. But yeah, tries are perfect for this sort of thing.. (I had assumed we were going for the quick fix). If you already have the trie version 1/2 implemented, it would be best. re: to vs. into: I did an informal test and it looks like to-array is a bit faster invocation-wise than into-array. The reason I said it might be faster to use into-array is because if the array is typed, we then know the type of its contents later, so it might be possible to reduce some reflection if you use that same array elsewhere, and end up using its contents in string manipulation functions (or if swing does that sort of thing at some point). -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en