diff --git a/+MATLAB/+Containers/IndexMap.m b/+MATLAB/+Containers/IndexMap.m index 7e44071..2b5ad98 100644 --- a/+MATLAB/+Containers/IndexMap.m +++ b/+MATLAB/+Containers/IndexMap.m @@ -43,15 +43,33 @@ % Value1,Value2,…,要添加的元素的值,可以重复指定多个要添加的新值 % # 返回值 % Keys,为添加的元素分配的新键,与每个输入值一一对应。 - NumAdd=numel(varargin); - NewCount=NumAdd+obj.Count; + Keys=obj.Allocate(numel(varargin)); + obj.CellArray(Keys)=varargin; + end + function Keys=Allocate(obj,Number) + % 预分配指定数目的新键,暂不赋值 + % 新键对应的值可能是未初始化的任意值 + % # 语法 + % Keys=obj.Allocate + % %分配一个新键 + % + % Keys=obj.Allocate(Number) + % %分配指定数目的新键 + % # 输入参数 + % Number=1,可选,分配新键的数目 + % # 返回值 + % Keys,分配的指定数目的新键 + arguments + obj + Number=1 + end + NewCount=Number+obj.Count; if NewCount>numel(obj.ValidLogical) NewCapacity=NewCount*2; obj.CellArray{NewCapacity}=[]; obj.ValidLogical(NewCapacity)=false; end - Keys=find(~obj.ValidLogical,NumAdd); - obj.CellArray(Keys)=varargin; + Keys=find(~obj.ValidLogical,Number); obj.ValidLogical(Keys)=true; end function Clear(obj) diff --git a/+MATLAB/Version.m b/+MATLAB/Version.m index 212d72d..1532928 100644 --- a/+MATLAB/Version.m +++ b/+MATLAB/Version.m @@ -1,4 +1,4 @@ function V = Version -V.Me='7.4.0'; +V.Me='7.4.1'; V.Win32API=Win32API.Version; V.MATLAB='R2022a'; \ No newline at end of file diff --git a/README.md b/README.md index c98e487..3a313a4 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,27 @@ Value1,Value2,…,要添加的元素的值,可以重复指定多个要添加 Keys,为添加的元素分配的新键,与每个输入值一一对应。 +**Allocate** +预分配指定数目的新键,暂不赋值 + +新键对应的值可能是未初始化的任意值 + +*语法* +```MATLAB +Keys=obj.Allocate +%分配一个新键 + +Keys=obj.Allocate(Number) +%分配指定数目的新键 +``` +*输入参数* + +Number=1,可选,分配新键的数目 + +*返回值* + +Keys,分配的指定数目的新键 + **Clear** 将所有键和值从IndexMap中移除。 diff --git a/resources/functionSignatures.json b/resources/functionSignatures.json index 16debd2..46954d0 100644 --- a/resources/functionSignatures.json +++ b/resources/functionSignatures.json @@ -85,143 +85,180 @@ } ] }, - "MATLAB.Containers.IndexMap.Items":{ - "inputs":[ + "MATLAB.Containers.IndexMap.Items": { + "inputs": [ { - "name":"Keys", - "kind":"ordered", - "type":"real", - "purpose":"要设置或指定的键向量" + "name": "obj", + "kind": "required" + }, + { + "name": "Keys", + "kind": "ordered", + "type": "positive", + "purpose": "要设置或指定的键向量" }, { - "name":"Value", - "kind":"ordered", - "purpose":"要设置的键值", - "repeating":true + "name": "Value", + "kind": "ordered", + "purpose": "要设置的键值", + "repeating": true } ] }, - "MATLAB.Containers.IndexMap.Add":{ - "inputs":[ + "MATLAB.Containers.IndexMap.Add": { + "inputs": [ { - "name":"Value", - "kind":"required", - "purpose":"要添加的元素的值", - "repeating":true + "name": "obj", + "kind": "required" + }, + { + "name": "Value", + "kind": "required", + "purpose": "要添加的元素的值", + "repeating": true } ] }, - "MATLAB.Containers.IndexMap.IsKey":{ - "inputs":[ + "MATLAB.Containers.IndexMap.Allocate": { + "inputs": [ { - "name":"Keys", - "kind":"required", - "type":"real", - "purpose":"要在 IndexMap 对象中搜索的键向量" + "name": "obj", + "kind": "required" + }, + { + "name": "Number", + "kind": "ordered", + "type": "positive", + "purpose": "分配新键的数目", + "default": 1 + } + ] + }, + "MATLAB.Containers.IndexMap.IsKey": { + "inputs": [ + { + "name": "obj", + "kind": "required" + }, + { + "name": "Keys", + "kind": "required", + "type": "positive", + "purpose": "要在 IndexMap 对象中搜索的键向量" } ] }, - "MATLAB.Containers.IndexMap.Remove":{ - "inputs":[ + "MATLAB.Containers.IndexMap.Remove": { + "inputs": [ + { + "name": "obj", + "kind": "required" + }, { - "name":"Keys", - "kind":"required", - "type":"real", - "purpose":"要从 IndexMap 对象中删除的键-值对组的键" + "name": "Keys", + "kind": "required", + "type": "positive", + "purpose": "要从 IndexMap 对象中删除的键-值对组的键" } ] }, - "MATLAB.Containers.IQueue.Contains":{ - "inputs":[ + "MATLAB.Containers.IQueue.Contains": { + "inputs": [ { - "name":"obj", - "kind":"required" + "name": "obj", + "kind": "required" }, { - "name":"Element", - "kind":"ordered", - "purpose":"要在队列中查找的对象", - "repeating":true + "name": "Element", + "kind": "ordered", + "purpose": "要在队列中查找的对象", + "repeating": true } ] }, - "MATLAB.Containers.IQueue.Dequeue":{ - "inputs":[ + "MATLAB.Containers.IQueue.Dequeue": { + "inputs": [ { - "name":"obj", - "kind":"required" + "name": "obj", + "kind": "required" }, { - "name":"Number", - "kind":"ordered", - "type":["real","scalar"], - "purpose":"要移除的对象个数。" + "name": "Number", + "kind": "ordered", + "type": [ + "real", + "scalar" + ], + "purpose": "要移除的对象个数。" } ] }, - "MATLAB.Containers.IQueue.Enqueue":{ - "inputs":[ + "MATLAB.Containers.IQueue.Enqueue": { + "inputs": [ { - "name":"obj", - "kind":"required" + "name": "obj", + "kind": "required" }, { - "name":"Element", - "kind":"required", - "purpose":"要添加到 Queue 的对象", - "repeating":true + "name": "Element", + "kind": "required", + "purpose": "要添加到 Queue 的对象", + "repeating": true } ] }, - "MATLAB.Containers.Queue":{ - "inputs:":[ + "MATLAB.Containers.Queue": { + "inputs:": [ { - "name":"Element", - "kind":"ordered", - "purpose":"要放入队列的初始元素", - "repeating":true + "name": "Element", + "kind": "ordered", + "purpose": "要放入队列的初始元素", + "repeating": true } ] }, - "MATLAB.Containers.Queue.Contains":{ - "inputs":[ + "MATLAB.Containers.Queue.Contains": { + "inputs": [ { - "name":"obj", - "kind":"required" + "name": "obj", + "kind": "required" }, { - "name":"Element", - "kind":"ordered", - "purpose":"要在队列中查找的对象", - "repeating":true + "name": "Element", + "kind": "ordered", + "purpose": "要在队列中查找的对象", + "repeating": true } ] }, - "MATLAB.Containers.Queue.Dequeue":{ - "inputs":[ + "MATLAB.Containers.Queue.Dequeue": { + "inputs": [ { - "name":"obj", - "kind":"required" + "name": "obj", + "kind": "required" }, { - "name":"Number", - "kind":"ordered", - "type":["real","scalar"], - "purpose":"要移除的对象个数。" + "name": "Number", + "kind": "ordered", + "type": [ + "real", + "scalar" + ], + "purpose": "要移除的对象个数。" } ] }, - "MATLAB.Containers.Queue.Enqueue":{ - "inputs":[ + "MATLAB.Containers.Queue.Enqueue": { + "inputs": [ { - "name":"obj", - "kind":"required" + "name": "obj", + "kind": "required" }, { - "name":"Element", - "kind":"required", - "purpose":"要添加到 Queue 的对象", - "repeating":true + "name": "Element", + "kind": "required", + "purpose": "要添加到 Queue 的对象", + "repeating": true } ] }, diff --git "a/\345\237\203\345\215\232\346\213\211\351\205\261 \347\232\204 MATLAB \346\211\251\345\261\225 Extension.prj" "b/\345\237\203\345\215\232\346\213\211\351\205\261 \347\232\204 MATLAB \346\211\251\345\261\225 Extension.prj" index 4eca954..5e13574 100644 --- "a/\345\237\203\345\215\232\346\213\211\351\205\261 \347\232\204 MATLAB \346\211\251\345\261\225 Extension.prj" +++ "b/\345\237\203\345\215\232\346\213\211\351\205\261 \347\232\204 MATLAB \346\211\251\345\261\225 Extension.prj" @@ -85,7 +85,7 @@ SaveFileDialog 可以设置初始目录,以及保存上次所在目录的文 InstallSupportPackages 安装下载好的支持包 SupportPackageDownloader 下载支持包下载器 ${PROJECT_ROOT}\图标.png - 7.4.0 + 7.4.1 ${PROJECT_ROOT}\埃博拉酱 的 MATLAB 扩展 Extension.mltbx