KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Dictionary Class Reference

A basic dictionary of key/value pairs for small to medium amounts of data. More...

Detailed Description

A basic dictionary of key/value pairs for small to medium amounts of data.

This simple dictionary basically wraps a nice interface around a matlab cell with the corresponding values. Due to the linear search for keys it is only suited for small to medium sized amounts of data.

Note
Despite the standard set/get methods one can also use the matlab-like subscripted notation to set and get values.
Example
d('somekey') = 'somevalue';
d('nr') = 2346;
d('myclass') = 'some object instance';
disp(d('nr'));
disp(d('myclass'));
disp(d('nonexistent'));
Author
Daniel Wirtz
Date
2011-04-06
See Also
The dict class at http://www.mathworks.com/matlabcentral/fileexchange/19647
Change in 0.6:
(Daniel Wirtz, 2012-01-17) Changed the clear method so that optionally a specific key can be passed in order to only remove one entry.
Change in 0.3:
(Daniel Wirtz, 2011-04-20) - Improved the subsref and subsasgn methods to forward eventual further sub-assignments to the respective underlying values. Now i.e. assignments of the type
d('t').Somefield
natively creates a struct at
d('t')
.
New in 0.3:
(Daniel Wirtz, 2011-04-06) Added this class.
Todo:
connect to/backup with tree structure for speedup.

Copyright (c) 2011, Daniel Wirtz All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted only in compliance with the BSD license, see http://www.opensource.org/licenses/bsd-license.php

Definition at line 17 of file Dictionary.m.

Public Member Functions

 Dictionary ()
 Creates a new empty dictionary. More...
 
function  set (char key,any value)
 Sets the dictionary entry for key key to value value The keys are unique, so if a key already exists the value is overwritten. More...
 
function value = get (char key)
 Returns the value for a given key, [] is the key does not exists inside the dictionary. More...
 
function  clear (key)
 Clears the dictionary or the contents for a specific key, if given. More...
 
function bool = containsKey (char key)
 Checks if the dictionary contains the key key. More...
 
function
varargout
subsref (key)
 Implements subscripted value retrieval. More...
 
function this = subsasgn (key, value)
 Implements subscripted assignment. More...
 
function  display ()
 Overrides the default display method in MatLab and prints a list of keys and values inside the dictionary. More...
 

Public Attributes

cell Keys
 The keys used in the dictionary. Readonly. More...
 
cell Values
 The values used in the dictionary. Readonly. More...
 
integer Count
 The size of the dictionary. Readonly. More...
 
- Public Attributes inherited from handle
 addlistener
 Creates a listener for the specified event and assigns a callback function to execute when the event occurs. More...
 
 notify
 Broadcast a notice that a specific event is occurring on a specified handle object or array of handle objects. More...
 
 delete
 Handle object destructor method that is called when the object's lifecycle ends. More...
 
 disp
 Handle object disp method which is called by the display method. See the MATLAB disp function. More...
 
 display
 Handle object display method called when MATLAB software interprets an expression returning a handle object that is not terminated by a semicolon. See the MATLAB display function. More...
 
 findobj
 Finds objects matching the specified conditions from the input array of handle objects. More...
 
 findprop
 Returns a meta.property objects associated with the specified property name. More...
 
 fields
 Returns a cell array of string containing the names of public properties. More...
 
 fieldnames
 Returns a cell array of string containing the names of public properties. See the MATLAB fieldnames function. More...
 
 isvalid
 Returns a logical array in which elements are true if the corresponding elements in the input array are valid handles. This method is Sealed so you cannot override it in a handle subclass. More...
 
 eq
 Relational functions example. See details for more information. More...
 
 transpose
 Transposes the elements of the handle object array. More...
 
 permute
 Rearranges the dimensions of the handle object array. See the MATLAB permute function. More...
 
 reshape
 hanges the dimensions of the handle object array to the specified dimensions. See the MATLAB reshape function. More...
 
 sort
 ort the handle objects in any array in ascending or descending order. More...
 

Constructor & Destructor Documentation

Dictionary.Dictionary ( )

Creates a new empty dictionary.

Definition at line 121 of file Dictionary.m.

Member Function Documentation

function Dictionary.clear (   key)

Clears the dictionary or the contents for a specific key, if given.

Pass no argument in order to clear the whole dictionary.

Parameters
keyA key whose key/value pair is to be removed from the dictionary. Default: []

Definition at line 156 of file Dictionary.m.

function bool = Dictionary.containsKey ( char  key)

Checks if the dictionary contains the key key.

Parameters
keyThe key whose existence is to check

Definition at line 182 of file Dictionary.m.

function Dictionary.display ( )

Overrides the default display method in MatLab and prints a list of keys and values inside the dictionary.

Definition at line 270 of file Dictionary.m.

References Count, and handle.disp.

function value = Dictionary.get ( char  key)

Returns the value for a given key, [] is the key does not exists inside the dictionary.

Parameters
keyThe key whose value is to be returned

Definition at line 143 of file Dictionary.m.

function Dictionary.set ( char  key,
any  value 
)

Sets the dictionary entry for key key to value value The keys are unique, so if a key already exists the value is overwritten.

Parameters
keyThe key for the value.
valueThe value for the key. :-) MatLab variable

Definition at line 130 of file Dictionary.m.

function this = Dictionary.subsasgn (   key,
  value 
)

Implements subscripted assignment.

See Also
subsasgn

Definition at line 223 of file Dictionary.m.

function varargout = Dictionary.subsref (   key)

Implements subscripted value retrieval.

See Also
subsref

Definition at line 203 of file Dictionary.m.

Member Data Documentation

Dictionary.Count

The size of the dictionary. Readonly.

Note
This property has the MATLAB attribute Dependent set to true.
Matlab documentation of property attributes.
[readonly]

Definition at line 106 of file Dictionary.m.

Referenced by display().

Dictionary.Keys

The keys used in the dictionary. Readonly.

Note
This property has the MATLAB attribute Dependent set to true.
Matlab documentation of property attributes.
[readonly]

Definition at line 80 of file Dictionary.m.

Dictionary.Values

The values used in the dictionary. Readonly.

Note
This property has the MATLAB attribute Dependent set to true.
Matlab documentation of property attributes.
[readonly]

Definition at line 93 of file Dictionary.m.


The documentation for this class was generated from the following file: