Re: How to use list effectively?



Why Tea wrote:
I have obtained a filelist with "find" in a clearcase vobs. There are
close to 10,000 files. I'm thinking of reading them into a list, then
for any given filename I can quickly search the list to obtain the full
path and spawn an external viewer. I'm sure there are other better and
more efficient ways of doing it. I'd appreciate any suggestion and
better still, with some sample code. Thanks.

It may be better to use an array with the file name as the key and the full path as the value (or list of values if you want to allow a file with the same name to exist in multiple directories).

Another option would be to use the full path (including the file name) as the key with a "1" as the value.

Either way, [array names fileArray $searchPattern] will give you the list you are looking for.

The search should be faster for 10,000 than lsearch.

--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
.



Relevant Pages

  • Re: Code Help
    ... for each filename in the list do ... your code doesn't define $_ anywhere and you are not opening or ... reading the files in your list anywhere, ... > file is read for words which are then pushed onto an array. ...
    (comp.lang.perl.misc)
  • Re: how to plot a image histogram to
    ... imread takes a filename, not an array. ... reading in some filename, then, like I said, just use your "Y" instead ... just use the axes() function to specify the current axes. ...
    (comp.soft-sys.matlab)
  • Re: How to use list effectively?
    ... Gerald W. Lester wrote: ... I'm thinking of reading them into a list, ... for any given filename I can quickly search the list to obtain the full ... It may be better to use an array with the file name as the key and the full ...
    (comp.lang.tcl)
  • Re: Help end the testing tedium please
    ... When you call it from Consolidate ... Please assume that both the filename and the ... worksheet name are sequential. ... the file really were test1 thru test60, would the array statement need ...
    (microsoft.public.excel.programming)
  • Re: Help end the testing tedium please
    ... When you call it from Consolidate ... Please assume that both the filename and the ... the file really were test1 thru test60, would the array statement need ... With Selection ...
    (microsoft.public.excel.programming)