[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: string dictionary class
From: |
coccoinomane |
Subject: |
Re: string dictionary class |
Date: |
Tue, 26 Jan 2010 08:52:01 -0800 (PST) |
HI Jaroslev!
Thank you very much for this addition. I downloaded it but I cannot
reproduce your examples. Upon typing
> gnusoft = dict
I get the following error message:
error: string cannot be indexed with .
error: called from:
error: ~/dict_from_svn/struct.m at line 26, column 8
error: evaluating argument list element number 1
error: evaluating argument list element number 1
error: ~/dict_from_svn/dict.m at line 82, column 5
I have Octave 3.2.3 on Mac Os X 10.6, aka Snow Leopard. Is my Octave version
too old? I would like to install the development version from source, but
last time I tried I had all sort of problems... an updatev version of
Octave.app would be wonderful :)
Cheers,
Guido
Jaroslav Hajek-2 wrote:
>
> hi all,
>
> I have contributed a simple string dictionary class to the `general'
> package, which comprises
>
> indexing by strings & cell string arrays
> indexed assignment
> inserting and deleting elements
> existence query (has)
> query with default value (get)
>
> it is intended to work with development version of Octave, as it uses
> some new features. The implementation uses binary lookup in a sorted
> array.
> operation complexity, w.r.t. number of existing keys N is:
> retrieve and query: O(log(N))
> set existing entry: O(log(N)) with the recent subsasgn optimization
> (e79470be3ecb), O(N) without it.
> insert new key / delete existing: O(N)
>
> it is therefore not suitable for frequent insertions but good when
> query is the major operation.
>
> Example usage:
>
> octave:1> gnusoft = dict
> gnusoft = dict: {}
> octave:2> gnusoft("octave") = "www.octave.org"
> gnusoft =
>
> dict: {
> octave : www.octave.org
> }
> octave:3> gnusoft("gcc") = "gcc.gnu.org"
> gnusoft =
>
> dict: {
> gcc : gcc.gnu.org
> octave : www.octave.org
> }
> octave:4> gnusoft({"octave", "gcc", "octave"})
> ans =
>
> {
> [1,1] = www.octave.org
> [1,2] = gcc.gnu.org
> [1,3] = www.octave.org
> }
>
> octave:5> getgnusoftaddress = @(name) get(gnusoft, name,
> "directory.fsf.org/GNU")
> getgnusoftaddress =
>
> @(name) get (gnusoft, name, "directory.fsf.org/GNU")
>
> octave:6> getgnusoftaddress ("octave")
> ans = www.octave.org
> octave:7> getgnusoftaddress ("bison")
> ans = directory.fsf.org/GNU
> octave:8> has(gnusoft, {"gcc", "bison"})
> ans =
>
> 1 0
>
> octave:9> mathgnusoft = gnusoft
> mathgnusoft =
>
> dict: {
> gcc : gcc.gnu.org
> octave : www.octave.org
> }
> octave:10> mathgnusoft ({"gcc"}) = []
> mathgnusoft =
>
> dict: {
> octave : www.octave.org
> }
> octave:11> files = dir;
> octave:12> cache_file_stat = dict ({dir.name}, {dir.statinfo});
> octave:13> cache_file_stat ("adresamp2.m")
> ans =
> {
> dev = 2051
> ino = 14749998
> mode = 33188
> modestr = -rw-r--r--
> nlink = 1
> uid = 1000
> gid = 100
> rdev = 0
> size = 2739
> atime = 1.2464e+09
> mtime = 1.2403e+09
> ctime = 1.2403e+09
> blksize = 4096
> blocks = 16
> }
>
>
> I welcome suggestions for improvements and enhancements.
>
> enjoy!
>
> --
> RNDr. Jaroslav Hajek
> computing expert & GNU Octave developer
> Aeronautical Research and Test Institute (VZLU)
> Prague, Czech Republic
> url: www.highegg.matfyz.cz
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>
>
--
View this message in context:
http://old.nabble.com/string-dictionary-class-tp24966944p27325923.html
Sent from the Octave - General mailing list archive at Nabble.com.
- Re: string dictionary class,
coccoinomane <=