classdef MaClasse < nelson.mixin.indexing.RedefinesBrace
| Paramètre | Description |
|---|---|
| obj | objet d'une classe derivee de nelson.mixin.indexing.RedefinesBrace. |
| Paramètre | Description |
|---|---|
| obj | objet prenant en charge une indexation par accolades personnalisee. |
Dérivez de nelson.mixin.indexing.RedefinesBrace pour donner à une classe son propre comportement d'indexation par accolades. Une sous-classe implémente les méthodes protégées braceReference(obj, indexOp) (valeur de obj{...}), braceAssign(obj, indexOp, value) (obj{...} = value) et braceListLength(obj, indexOp, indexContext).
indexOp est un nelson.indexing.IndexingOperation dont la propriété Indices est un tableau de cellules des indices.
classdef Bag < nelson.mixin.indexing.RedefinesBrace
properties
Data
end
methods
function obj = Bag(x)
obj.Data = x;
end
end
methods (Access = protected)
function varargout = braceReference(obj, indexOp)
varargout{1} = obj.Data{indexOp.Indices{1}};
end
function obj = braceAssign(obj, indexOp, val)
obj.Data{indexOp.Indices{1}} = val;
end
function n = braceListLength(obj, indexOp, ctx)
n = 1;
end
end
end
| Version | Description |
|---|---|
| 2.0.0 | version initiale |