-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
埃博拉酱
committed
Apr 10, 2022
1 parent
045318a
commit 8686b2b
Showing
7 changed files
with
238 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
classdef IndexMap<handle | ||
% IndexMap是一种自动分配键的映射 | ||
% 添加值时不能手动指定键,只能接受自动分配的返回键;访问时则跟映射相同,用键访问。 | ||
properties(Access=private) | ||
CellArray cell | ||
ValidLogical logical | ||
end | ||
methods | ||
function C=Count(obj) | ||
% 返回对象中的键-值对组的数量 | ||
C=sum(obj.ValidLogical); | ||
end | ||
function Values=Items(obj,Keys,varargin) | ||
% 获取或设置与指定的键关联的值。 | ||
% # 语法 | ||
% Values=obj.Items | ||
% %以元胞数组的形式返回输入 IndexMap 对象的所有值。 | ||
% | ||
% Values=obj.Items(Keys) | ||
% %返回与Keys中指定的键对应的值。输出参数 Values 的大小与 Keys 相同。 | ||
% | ||
% obj.Items(Keys,Value1,Value2,…) | ||
% %设置指定键的值 | ||
% # 输入参数 | ||
% Keys,要设置或指定的键向量。请使用从Add返回的键,自定义键可能会产生意外问题。如不指定此参数,将返回所有值。 | ||
% Value1,Value2,…,可选,要设置的键值。如果设置此参数,键向量长度和值的个数必须相同。 | ||
% # 返回值 | ||
% Values,指定键对应的值排列成元胞向量。如未指定Keys,将返回所有值。 | ||
if nargin>1 | ||
if ~isempty(varargin) | ||
obj.CellArray(Keys)=varargin; | ||
end | ||
Values=obj.CellArray(Keys); | ||
else | ||
Values=obj.CellArray(obj.ValidLogical); | ||
end | ||
end | ||
function Keys=Add(obj,varargin) | ||
% 将指定的值添加到IndexMap中,返回自动分配的新键。 | ||
% # 语法 | ||
% Keys=obj.Add(Value1,Value2,…) | ||
% # 输入参数 | ||
% Value1,Value2,…,要添加的元素的值,可以重复指定多个要添加的新值 | ||
% # 返回值 | ||
% Keys,为添加的元素分配的新键,与每个输入值一一对应。 | ||
NumAdd=numel(varargin); | ||
NewCount=NumAdd+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; | ||
obj.ValidLogical(Keys)=true; | ||
end | ||
function Clear(obj) | ||
% 将所有键和值从IndexMap中移除。 | ||
% Count属性设置为0,但不会立即释放对集合的元素的其他对象的引用。如有必要请先手动delete对象。 | ||
obj.ValidLogical(:)=false; | ||
end | ||
function IK=IsKey(obj,Keys) | ||
% 确定 IndexMap 对象是否包含键 | ||
% # 语法 | ||
% IK=obj.IsKey(Keys) | ||
% %如果 obj 包含指定的键,将返回 1 (true),否则将返回 0 (false)。如果 Keys 是指定多个键的数组,则 IK 是具有相同大小的逻辑数组。 | ||
% # 输入参数 | ||
% Keys,要在 IndexMap 对象中搜索的键向量 | ||
% # 返回值 | ||
% IK,指示每个键是否存在的逻辑向量。 | ||
IK=Keys<=numel(obj.ValidLogical); | ||
IK(IK)=obj.ValidLogical(Keys(IK)); | ||
end | ||
function K=Keys(obj) | ||
% 返回一个向量,其中包含 IndexMap 对象中的所有键。 | ||
K=find(obj.ValidLogical); | ||
end | ||
function Remove(obj,Keys) | ||
% 从 IndexMap 对象中删除键-值对组 | ||
% # 语法 | ||
% obj.Remove(Keys) | ||
% %从输入 IndexMap 对象中删除指定的键以及与它们关联的值。 | ||
% # 输入参数 | ||
% Keys,要从 IndexMap 对象中删除的键-值对组的键。对应的值也被删除,但不会立即释放对集合的元素的其他对象的引用。如有必要请先手动delete对象。 | ||
obj.ValidLogical(Keys)=false; | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
function V = Version | ||
V.Me='7.3.1'; | ||
V.Me='7.4.0'; | ||
V.Win32API=Win32API.Version; | ||
V.MATLAB='R2022a'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
resources/project/LT7eQAZ4uef27PCfN7eQribLo58/S9v2lVBhiX80cTl9ExcpobAmmIEd.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<Info> | ||
<Category UUID="FileClassCategory"> | ||
<Label UUID="design"/> | ||
</Category> | ||
</Info> |
2 changes: 2 additions & 0 deletions
2
resources/project/LT7eQAZ4uef27PCfN7eQribLo58/S9v2lVBhiX80cTl9ExcpobAmmIEp.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<Info location="IndexMap.m" type="File"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
<param.authnamewatermark>埃博拉酱</param.authnamewatermark> | ||
<param.email>[email protected]</param.email> | ||
<param.company /> | ||
<param.summary>埃博拉酱的MATLAB扩展工具包,提供一系列MATLAB内置函数所欠缺,但却常用的增强功能(部分功能仅支持Windows系统)。例如,队列实现,类 SQL SELECT 多表查询,返回数组最大值的坐标,带误差阴影的多线图,许多内置函数的功能强化升级版……</param.summary> | ||
<param.summary>埃博拉酱的MATLAB扩展工具包,提供一系列MATLAB内置函数所欠缺,但却常用的增强功能(部分功能仅支持Windows系统)。例如,各种容器类,类 SQL SELECT 多表查询,返回数组最大值的坐标,带误差阴影的多线图,许多内置函数的功能强化升级版……</param.summary> | ||
<param.description>埃博拉酱的MATLAB扩展工具包,提供一系列MATLAB内置函数所欠缺,但却常用的增强功能。依赖Win32API | ||
|
||
本项目的发布版本号遵循语义化版本规范。开发者认为这是一个优秀的规范,并向每一位开发者推荐遵守此规范。 | ||
|
@@ -19,6 +19,7 @@ PublishRequirements 在包目录下生成一个依赖项.mat文件 | |
+AudioVideo | ||
VideoPreview 生成一张图片作为视频文件的预览 | ||
+Containers | ||
@IndexMap IndexMap是一种自动分配键的映射 | ||
@IQueue 一个接口,表示对象的先进先出集合。 | ||
@Queue IQueue的简单基本实现 | ||
+DataFun | ||
|
@@ -84,7 +85,7 @@ SaveFileDialog 可以设置初始目录,以及保存上次所在目录的文 | |
InstallSupportPackages 安装下载好的支持包 | ||
SupportPackageDownloader 下载支持包下载器</param.description> | ||
<param.screenshot>${PROJECT_ROOT}\图标.png</param.screenshot> | ||
<param.version>7.3.1</param.version> | ||
<param.version>7.4.0</param.version> | ||
<param.output>${PROJECT_ROOT}\埃博拉酱 的 MATLAB 扩展 Extension.mltbx</param.output> | ||
<param.products.name /> | ||
<param.products.id /> | ||
|
@@ -182,7 +183,6 @@ SupportPackageDownloader 下载支持包下载器</param.description> | |
<fileset.rootfiles> | ||
<file>${PROJECT_ROOT}\+MATLAB</file> | ||
<file>${PROJECT_ROOT}\+MatlabShared</file> | ||
<file>${PROJECT_ROOT}\matlab.mat</file> | ||
<file>${PROJECT_ROOT}\README.md</file> | ||
<file>${PROJECT_ROOT}\resources</file> | ||
<file>${PROJECT_ROOT}\示例数据</file> | ||
|