octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: [OctDev] string dictionary class


From: c.
Subject: Fwd: [OctDev] string dictionary class
Date: Mon, 13 Jan 2014 21:31:24 +0100

Hi,

I saw you were discussing what's the purpose of 
@dict in the package general so I looked up the 
orginal message that Jaroslav sent when he created
that class explaining its purpose.

HTH,
c.

Begin forwarded message:

> From: Jaroslav Hajek <address@hidden>
> Subject: [OctDev] string dictionary class
> Date: 14 August 2009 08:29:24 GMT+2
> To: octave-forge list <address@hidden>
> Cc: Octave users list <address@hidden>
> 
> 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
> 
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with 
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Octave-dev mailing list
> address@hidden
> https://lists.sourceforge.net/lists/listinfo/octave-dev



reply via email to

[Prev in Thread] Current Thread [Next in Thread]