This file is indexed.

/usr/share/octave/packages/general-1.3.4/@dict/dict.m is in octave-general 1.3.4-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
## Copyright (C) 2009 VZLU Prague, a.s., Czech Republic
##
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 3 of the License, or (at your option) any later
## version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program; if not, see <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
## @deftypefn  {Function File} {} dict ()
## @deftypefnx {Function File} {} dict (@var{keys}, @var{values})
## @deftypefnx {Function File} {} dict (@var{str})
## Creates a dictionary object with given keys and values.
##
## The class @code{dict} has been deprecated in favour of using Octave
## structs.  The advantage of dict over structs was that dict allowed any
## string, not only valid Octave identifiers, as fieldnames.  This has
## since change and any string is now a valid fieldname.
##
## @example
## @group
## s = struct ("7", "value7", "  ", "just spaces");
## s.("7")
##   @result{} "value 7"
## s.("  ")
## @result{} just spaces
##   @result{} "just spaces"
## @end group
## @end example
##
## @var{keys}
## should be a cell array of strings; @var{values} should be a cell array
## with matching size. @var{values} can also be a singleton array, in
## which case it is expanded to the proper size; or omitted, in which case
## the default value of empty matrix is used.
## If neither @var{keys} nor @var{values} are supplied, an empty dictionary
## is constructed.
## If a scalar structure is supplied as an argument, it is converted to 
## a dictionary using field names as keys.
##
## A dictionary can be indexed either by a single string or cell array of
## strings, like this:
##
## @example
## @group
##   d = dict (keys, values);
##   d(str) # result is a single value
##   d(cellstr) # result is a cell array
## @end group
## @end example
##
## In the first case, the stored value is returned directly; in the second case,
## a cell array is returned. The cell array returned inherits the shape of the index.
## 
## Similarly, indexed assignment works like this:
##
## @example
## @group
##   d = dict (keys, values);
##   d(str) = val; # store a single value
##   d(cellstr) = vals; # store a cell array
##   d(cellstr) = []; # delete a range of keys
## @end group
## @end example
##
## Any keys that are not present in the dictionary are added. The values of
## existing keys are overwritten. In the second case, the lengths of index and
## rhs should match or rhs should be a singleton array, in which case it is
## broadcasted. 
##
## It is also possible to retrieve keys and values as cell arrays, using the
## "keys" and "values" properties. These properties are read-only.
##
## @end deftypefn

## Author: Jaroslav Hajek <highegg@gmail.com>

function d = dict (keys, values)

  persistent warned = false;
  if (! warned)
    warned = true;
    warning ("Octave:deprecated-function",
             ["`dict' has been deprecated in favor of structs which in " ...
              "Octave allows the use of arbitrary strings as fieldnames."]);
  endif

  if (nargin == 0)
    keys = values = cell (0, 1);
  elseif (nargin == 1)
    if (iscellstr (keys))
      keys = sort (keys(:));
      values = cell (numel (keys), 1);
    elseif (isstruct (keys))
      values = struct2cell (keys)(:,:);
      if (columns (values) != 1)
        error ("dict: structure must be a scalar");
      endif
      [keys, ind] = sort (fieldnames (keys));
      values = values(ind);        
    else
      error ("dict: keys must be a cell vector of strings");
    endif
  elseif (nargin == 2)
    [keys, idx] = sort (keys(:));
    values = values (idx)(:);
  else
    print_usage ();
  endif

  d = class (struct ("keys", {keys}, "values", {values}), "dict");

endfunction

%!test
%! free = dict ();
%! free({"computing", "society"}) = {true};
%! assert (free("computing"), free("society"));