using System;
using System.Collections; // 集合
using System.Collections.Generic; // 泛型集合
namespace 集合之HashTable
{
class Person {
public string user_Name;
public int user_Id;
}
class MainClass
{
public static void Main (string[] args)
{
// 为什么要引入集合概念:
// 演示数组的局限性
// 1.数组的局限性
// 数组只能存储相同类型的数据,比如int[] 数组只能存储int数据
// 2.数组存在大量垃圾数据
// string[] strs = new string[2];
// strs[0] = "张三";
// strs[1] = "张三";
// foreach (string item in strs) {
// Console.WriteLine (item);
// }
// 3.数组不能动态的扩展长度
// 集合
// Hashtable;
// ArrayList;
// Stack;
// Queue;
// 泛型集合
// ArrayList --> List<T>
// ArrayList al = new ArrayList();
// List<int> li = new List<int>();
// Hashtable --> Dictionary<Type,Type>
// HashTable
// Key -> value
// Key2 -> value
// 这里的key是唯一的
// Hashtable ht = new Hashtable();
// ht.Add (001,"老王");
// ht.Add (002,"老王2");
// ht.Add (003,"老王3");
// // 通过key取value
// Console.WriteLine (ht[001]);
//
// // 通过一个key移除一个value值
// ht.Remove(001);
//
// // 全部移除
// ht.Clear();
// 查找Key || value
// if (ht.Contains(001)) {
// Console.WriteLine ("True");
// }
//
// if (ht.ContainsKey(001)) {
// Console.WriteLine ("True");
// }
// if (ht.ContainsValue("老王")) {
// Console.WriteLine ("True");
// }
// // 遍历所有的key
// foreach (var item in ht.Keys) {
// Console.WriteLine (item);
// }
//
// // 遍历所有的value
// foreach (var item in ht.Values) {
// Console.WriteLine (item);
// }
// 遍历所有key - value
Hashtable ht = new Hashtable();
Person p1 = new Person();
p1.user_Name = "老王";
p1.user_Id = 1001;
Person p2 = new Person();
p2.user_Name = "老张";
p2.user_Id = 1002;
ht.Add (p1.user_Id, p1);
ht.Add (p2.user_Id, p2);
// 获取字段枚举遍历器
IDictionaryEnumerator ide = ht.GetEnumerator();
while (ide.MoveNext()) {
// ide.Entry;
// 将取出的内容转换成字典实体
DictionaryEntry de = (DictionaryEntry)ide.Current;
// 通过字典实体内的字段value 取出当时你存value时候的对象P,取出来的对象
// 需要转换(和你当时存的value类型是一致的)
Person per = de.Value as Person;
Console.WriteLine ("用户的id:{0},用户的姓名:{1}",per.user_Id,per.user_Name);
}
}
}
}相关推荐
机器人路径规划:基于冠豪猪优化算法(Crested Porcupine Optimizer,CPO)的机器人路径规划(提供MATLAB代码)
移动机器人(Mobile robot,MR)的路径规划是 移动机器人研究的重要分支之,是对其进行控制的基础。根据环境信息的已知程度不同,路径规划分为基于环境信息已知的全局路径规划和基于环境信息未知或局部已知的局部路径规划。随着科技的快速发展以及机器人的大量应用,人们对机器人的要求也越来越高,尤其表现在对机器人的智能化方面的要求,而机器人自主路径规划是实现机器人智能化的重要步骤,路径规划是指规划机器人从起点位置出发,无碰撞、安全到达指定目标位置的最优路径。
C# HashTable深度解析
先例举几个问题:1,Hashtable为什么速度查询速度快,而添加速度相对慢,且其添加和查询速度之比相差一个数量等级? 2,装填因子( Load Factor)是什么,hashtable默认的装填因子是多少? 3,hashtable里的元素是顺序排序的吗?
Tesseract in Java - Intellij IDEA对Tess4J的配置和使用
最近要弄OCR,搜到这个,官网全英文,很烦,看看有没有中文的博客介绍,擦,一个比一个奇葩,还是自己按照官方的来吧,外网慢的很,传到csdn给大家下载。中文训练库下载地址: http://download.csdn.net/detail/d_dmelon/9916532Tess4J3.4下载地址: http://download.csdn.net/detail/d_dmelon/9916519安装
遍历HashTable的几种方法
前两天学习了下HashTable遍历数据的方法,zaiwangshang
欧姆龙485通讯示例程序_【精品实验】PLC学习神器与温湿度变送器的通讯
BFH点击蓝字关注我们↑↑↑↑ PLC学习神器提供RS485接口,可支持无协议RS指令、无协议RS2指令、Modbus通讯功能,可通过设置通讯格式改变通讯协议,RS485对应的通讯格式地址是D8400; 本案例以RS485接口与温湿度变送器通讯,通讯格式如下一温湿度变送器的说明书介绍1.1主要技术参数1.2 通讯协议 1、所有通讯回路都应遵照主/从方式。依照主从方式,数据可以在一个主...
【异常】OpenClaw网关仪表盘 pairing required 报错排查与解决方案
在OpenClaw网关仪表盘页面,完成WebSocket URL、网关令牌等必填项配置后,点击「连接」按钮尝试建立网关连接时,页面下方出现红色报错提示框,核心报错内容为,无法完成网关连接建立,且该报错在令牌配置正确、网络链路通畅的场景下仍会触发。该报错常见于非本地回环地址的访问场景,包括局域网远程访问、公网域名/IP访问、云服务器部署的网关远程管理等场景,本地127.0.0.1回环地址访问通常可正常连接。
C语言的HashTable简单实现
HashTable是在实际应用中很重要的一个结构,下面讨论一个简单的实现,虽然简单,但是该有的部分都还是有的。 一,访问接口 创建一个hashtable. hashtable hashtable_new(int size) // size表示包含的接点个数。 存入key-value至hashtable中。 void hashtable_put(hashtable h,const ch...
面试问题总结——关于YOLO系列(一)
自从刚开始接到的第一个面试开始,到现在为止,陆陆续续也参加了许多场,我像是一个刚从新手村出来的小白,一路的打怪升级刷经验,期间遇到了很多不会的,我都会及时记录总结。 到现在仍然清晰记得,第一次去面试的时候,当时被怼的多惨。。。 说明:本人是非科班出身,本科是机械电子工程专业,硕士期间的研究方向是机器学习和深度学习,因为我的简历上有关于YOLO的项目,所以我着重准备了YOLO系列的面试可能遇到的问题。 决定开启这个面试问题总结的系列,包括YOLO、C++的内容、OpenCV的内容和深度学习方面被提问的问题
Hashtable集合
Hashtable集合 Hashtable集合和vector集合一样,在jdk 1.2版本之和被更先进的集合(HashMap,ArrayList)取代啦 Hashtable集合的子类Propertist依然活跃在历史舞台 Propertist集合是唯一和IO流相结合的集合 Hashtable与HashMap集合的不同: 1.Hashtable集合:底层也是一个哈希表,是一个线程安全...
液态神经网络(Liquid Neural Networks)从线虫大脑到下一代 AI
液态神经网络(Liquid Neural Networks,LNN)是一类具有动态内部结构的神经网络,其灵感来源于生物神经系统,尤其是大脑中神经元如何以复杂、非线性的方式响应外部刺激。与传统神经网络不同,液态神经网络的每个神经元在处理输入时,不再是静态线性或非线性变换,而是基于一个微分方程模型进行响应。这种建模方式使神经元的行为具有时间连续性和动态适应性。换句话说,它不仅“记住”过去的信息,还能根据当前环境实时调整自身的动态特性,这对于感知、决策、预测等任务都非常关键。
国科大学习资料--计算机视觉--期末考试解析
国科大学习资料–计算机视觉(胡占义)–期末考试解析 ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
HashTable集合
HashTable是Map另一个实现类,此类实现了一个哈希表,该哈希表将键映射到相应的值。任何非null对象都可以用作键或值。即不允许存储null对象(其他集合是允许的)。 JDK1.0版本就存在的,是最早期的双列集合。线程安全,是同步的(单线程,速度慢)。 HashTable:底层是一个哈希表,是一个线程安全的集合,是单线程集合,速度慢。 HashMap:底层是一个哈希表,是一个线程不安全的集合,是多线程的集合,速度快。 HashMap集合(以及之前学的所有集合):可以存储null值/键。 Ha
无人机威胁检测(Hostile Drone Detection)——基于YOLOv10与UI界面的实现
Anti-UAV数据集由多种场景下的无人机视频与图片组成,包含无人机目标的多样化姿态、背景、光照变化,专门用于反无人机检测研究。YOLO(You Only Look Once)系列是当前流行的实时目标检测算法,具有速度快、精度高的特点。网络结构优化:更深更轻的主干网络,提升特征提取能力。检测头改进:多尺度特征融合,更好检测小型目标如无人机。训练技巧:使用自动混合精度训练(AMP)、数据增强、标签平滑等技术。
C# HashTable集合遍历
C# HashTable集合遍历 作者:秋名 撰写时间:2020 年05 月27日 技术点:Hashtable类表示键/值对的集合,这些键/值对根据键的哈希代码进行组织, 每个元素都是一个存储在 DictionaryEntry 对象中的键/值对。键不能为 null,但值可以。 using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using
文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况
主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。
efm32 入门.pdf
本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。
【JAVA-Day55】Java集合类HashTable解析
在本篇技术博客中,作为博主,我将深入探讨Java中的Hashtable集合类,为你提供全面的了解。我们将从Hashtable的基本概念开始,逐步深入,讨论其内部工作原理、性能、线程安全性,以及在现代Java框架中的应用。还将探讨Hashtable的未来发展趋势和替代选择,以帮助你更好地应用这一重要工具。通过本文,我们对Java中的Hashtable集合类有了深入的了解。我们介绍了其基本概念、与HashMap的比较、内部工作原理、性能、线程安全性以及最佳实践。
迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)
迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)
C# Hashtable 集合
Hashtable特点 有集合的特点 Hashtable通过键值索引对应的元素 Hashtable创建 Hashtable ht = new Hashtable(); Hashtable方法 添加集合元素:ht.Add(键值,数据);(键值可以是数字或字符) 访问集合元素:ht[键值]; Foreach集合遍历方法 ...
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
Map集合类——HashTable
HashTable认识 HashTable 常用的映射功能和HashMap类似; 继承Dictionary类; 线程安全的集合类,任一时间只能有一个线程写hashtable;并发性不如ConcurrentHashMap,因为ConcurrentHashMap引入了Segment分段锁; 在不需要线程安全中建议使用HashMap;需要线程安全的地方使用ConcurrentHashMa...
集合笔记之HashTable
/1,底层由数组 Hashtable$Entry[]初始化大小为11,数组里面存链表,链表不会不像HashMap一样变成红黑树。//4.执行方法 addEntry(hashikey,value,index);//按照 int newCapacity=(oldcapacity
类Hashtable(集合)
概述 java.util.Hashtable<K,V>集合 implements Map<K,V>接口 Hashtable:底层也是一个哈希表,是一个线程安全的集合,是单线程集合,速度慢 HashMap:底层是一个哈希表,是一个线程不安全的集合,是多线程的集合,速度快 HashMap集合(之前学的所有的集合):可以存储null值,null键 Hash...
C# 字典集合HashTable与泛型集合Dictionary
字典集合HashTable与泛型集合Dictionary 特点:保证了数据的安全性与完整性 字典集合HashTable namespace _94字典集合HashTable与泛型集合Dictionary { /// <summary> /// 客户类 /// </summary> public class Customer { private string name; public string Name
浅谈Hashtable集合独特之处(面试题目)
浅谈Hashtable集合独特之处 java.util.Hashtable<k,v>集合 implements Map<k,v>接口 特点:(也是与其他集合的不同点) 1.是一个线程安全的集合,单线程的集合,效率低下 2.不允许存储null值,null键 Hashtable集合效率低下,已经被HashMap(允许存储null值,null键)给取代了,但是Hashtable...
Map集合,HashMap和HashTable的区别,集合嵌套
Map集合,HashMap和HashTable的区别,集合嵌套 Map集合 (1)概述: Map称为双列集合,由键和值组成 假如我有这种数据 键 值 000---------------------张三 001----------------------李四 002----------------------王五 Java针对这种键值映射...
Java集合————HashTable
HashTable 基本知识 1、HashTable是一种以键值对的方式存储的集合 2、HashTable是一种无序的集合 3、HashTable是通过HashCode来存放元素的集合 4、HashTable是元素不可重复的集合(键不可重复) 5、HashTable是一个线程安全的集合(与HashMap的区别) 6、HashTable直接在方法上加锁,效率低 7、HashTable的不许存入null键null值 创建集合 Hashtable集合是以键值对的形式的集合,在创建时就必须规定键和值的泛型,并且键和
HashMap集合、TreeMap集合、HashTable集合
Map 双列集合 Key,value 以"键/值"对存放元素 键值(Key)不可重复,值(value)可重复 一般把键值对称为映射 HashMap 键值不能重复,并且无序,可以键和值都可以存放null值 线程不安全 底层结构跟HashSet一样 put(K Ket,V value) 添加到集合中的键值对,如果有...
1368




被折叠的 条评论
为什么被折叠?



