HashMap源码分析

HashMap实现原理及源码分析 在数据结构与算法中,给我们介绍了常用的几种数据结构:数组,链表,哈希表。 数组结构:其在内存分配是一段连续的内存空间,可能会占用内存空间严重,空间复杂度很大,时间复杂度小,其优点是易于寻址,但是插入、删除困难。 链表结构:其在内存分配是一系列离散的内存空间,占用内存少,空间复杂度很小,时间复杂度很大,其优点是易于插入和删除,寻址困难。 哈希表:哈希表是集合数组和链表的存储结构,满足寻址方便,易于操作,占用内存空间较小,时间复杂度有较小。其例如下: 阅读详情

1、hashmap属性概念

HashMap中傻傻分不清楚的那些概念_Hollis Chuang的博客-优快云博客_hashmap桶子指的是啥

2、源码分析

https://www.cnblogs.com/xiaoxi/p/7233201.html

简介

HashMap为数组+链表+红黑树的数据结构

1、如何hash

static final int hash(Object key) {
    int h;
    return (key == null) ? 0 : (h = key.hashCode()) ^ (h >>> 16);
}

2、何时扩容

键值对大于阀值时或者初始化时,就调用resize方法进行扩容

 

3、怎么扩容(2n)

数组大小扩容为原来的2倍

4、何时由链表变成红黑树

链表大小>8,并且数组长度>64

5、如何获得原Node

 

n为数组长度
(p = tab[i = (n - 1) & hash])

备注:

static final int hash(Object key) {
    int h;
    return (key == null) ? 0 : (h = key.hashCode()) ^ (h >>> 16);
}
SAP SD模块定价过程后台配置简介 只有手工输入定价时(例如,在定价中的定价浏览屏幕中),或者只有从外部处理转移这些定价时(例如,成本核算),才将这些定价包括在确定(价格确定、输出确定,批次确定)之中。定价过程的定义和分配是SD模块中最核心的配置,包含了条件表、条件类型、存取顺序、发票类型、客户定价过程等,确定了销售订单已什么价格销售、税率、附加折扣等多个条件行程有一个定价过程。12、小计:记录该条件类型在VBAP表中是否存储,以及其后续用途,如记入信贷,占用信贷额度,记入成本等,如果需要金额暂用信贷额度的话,在小计这里选择A即可。 阅读详情

相关推荐

中介效应、调节效应与交互效应:从概念辨析到统计建模全指南

在社会科学与数据分析研究中,理解变量之间的因果关系与条件性影响是核心任务之一。回归分析作为最基础的统计工具,常被用于探索自变量对因变量的作用机制,而中介效应与调节效应则分别回答了“如何影响”与“何时影响不同”的深层问题。中介效应通过路径分析拆解因果链条,揭示内部的传导机制;调节效应则借助交互项识别影响的边界条件。Bootstrap法已成为检验间接效应的主流手段,而简单斜率分析则让调节作用的模式更加直观。无论是用户研究、医学统计还是产品数据分析,掌握这些模型都能帮助研究者构建更具解释力的实证框架。本文基于大量

weixin_29051149的博客 330

HashMap 源码分析

loadFactor 负载因子是控制数组存放数据的疏密程度,loadFactor 越趋近于 1,那么 数组中存放的数据(entry)也就越多,也就越密,也就是会让链表的长度增加,loadFactor 越小,也就是趋近于 0,数组中存放的数据(entry)也就越少,也就越稀疏。判断当前元素存放的位置(这里的 n 指的是数组的长度),如果当前位置存在元素的话,就判断该元素与要存入的元素的 hash 值以及 key 是否相同,如果相同的话,直接覆盖,不相同就通过拉链法解决冲突。默认的初始化大小为 16。

Wzideng@qq.com 1445

ESP32驱动GC9A01圆形屏实战:Arduino平台LVGL移植与图像显示优化

本文详细介绍了在Arduino平台上使用ESP32驱动GC9A01圆形屏的实战指南,包括硬件连接、LVGL移植与图像显示优化。通过SPI配置、LVGL库安装和双缓冲机制等技巧,帮助开发者快速实现高效显示效果,适用于智能家居控制面板等应用场景。

weixin_29182481的博客 735

HashMap和ConcurrentHashMap 源码分析

注:本文所述为JDK1.8版本 HashMap和ConcurrentHashMap源码分析 1、HashMap 1.1 概述 HashMap底层是基于数组+链表+红黑树组成的。 数据结构示例图: 主要属性: static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; // aka 16 static final int MAXIMUM_CAPACITY = 1 << 30; static .

loki的博客 283

EBS开发_离散工单创建API

--以下代码于20171213在TONY环境中实现 DECLARE     l_iface_rec    wip.wip_job_schedule_interface%ROWTYPE; --工单任务接口表     l_group_id     NUMBER;     l_returnstatus VARCHAR2(40);     l_errormsg     VARCHAR2(2000

蜗牛先生快跑的博客 2596

FAST-LIO2实战:从零搭建香港大学火星实验室SLAM框架(附官方数据集测试指南)

本文提供了一份详细的FAST-LIO2实战指南,帮助读者从零开始搭建香港大学火星实验室开源的这一高效激光惯性里程计框架。内容涵盖系统环境配置、依赖安装、源码编译、官方数据集测试以及参数调优,旨在让开发者快速上手并应用于机器人SLAM项目。

ppp33的博客 688

HashMap源码分析与常见八股

当链表的长度大于TREEIFY_THRESHOLD(默认为8)时会开始转化,同时要判断Node数组的个数是否大于MIN_TREEIFY_CAPACITY(默认64),如果小于就会先进行扩容,而不是转化,如果大于就直接转化为红黑树。时,会转化,如果当前数组长度小于64就学会先进行数组扩容,否则就转化为红黑树,默认大小为16,每次扩容2倍。拉链法就是使用一个链表数组,数组中的每一格都是一个链表,如果遇见哈希冲突,则将冲突的值加到链表中。可能是一个空元素,也可能是链表已存在,所以要区别对待。

m0_74047598的博客 2002

OCTA-500:用于光学相干断层扫描血管造影研究的视网膜数据集|文献速递-基于生成模型的数据增强与疾病监测应用

数据集提供了丰富的图像和注释,包括两种模态(OCT/OCTA体积)、六种投影类型、四种文本标签(年龄/性别/眼别/疾病)以及七种分割标签(大血管/毛细血管/动脉/静脉/2D FAZ/3D FAZ/视网膜层)。我们介绍了新的 OCTA-500 数据集,该数据集包含来自 500 名受试者的 OCTA 成像,并提供了丰富的图像和标注集。(C) OCTA-500 切片的人工标注示例。图 4. OCTA-500 数据集中文本标签的统计直方图:(a) 性别,(b) 眼别,(c) 年龄,(d) 疾病。

weixin_38594676的博客 1436

HashMap的源码分析

来源:https://www.cnblogs.com/beppezhang/p/6567478.html hashMap的底层实现是 数组+链表 的数据结构,数组是一个Entry<K,V>[] 的键值对对象数组,在数组的每个索引上存储的是包含Entry的节点对象,每个Entry对象是一个单链表结构,维护这下一个Entry节点的引用;有点绕,用个图来展示吧: Entry<K...

rentian1的博客 153

五步教你用GPT-5画出国自然技术路线图!轻松节省80%画图时间(附AI提示词)

七哥给大家推荐的高校都在用的AI平台——高级学术版专业应用平台,集成了ChatGPT、Claude、Gemini、Grok等Al大模型的PLUS版本平台,包括 ChatGPT-5、4o、o3、4.1、4.5、Gemini 2.5 Pro、Claude 3.7、Claude 4、DeepSeek 满血版、Grok 3 、Grok 4等原生线路,还有国际主流的GPTs学术应用,可以辅助大家高效完成科研和学术写作任务,当然撰写硕博论文,课题、职称论文、国社科、国自然基金本子也是手拿把掐。

智能AI让学术科研更容易 1500

NL2SQL进阶系列(3):Data-Copilot、Chat2DB、Vanna Text2SQL优化框架开源应用实践详解[Text2SQL]

NL2SQL进阶系列(3):Data-Copilot、Chat2DB、Vanna Text2SQL优化框架开源应用实践详解[Text2SQL]

丨汀、的博客 5421

HashMap扩容机制源码分析

前几天写了一篇,ArrayList扩容源码分析。好像源码也没有我们想象的那么可怕?(当然了,只是简单的分析,后面等我知识充足了,将进一步的分析) 今天本来想打游戏的,但是网速太差了,真是的是让人火爆。努力写代码,将来租一个网速好的房子 1、具体看源码之前,我们先简单的说一下HashMap的底层数据结构     1、HashMap底层的数据结构是 数组 ...

小道仙的后宫 1584

Holosoma 开源人形机器人强化学习训练部署框架

Holosoma是一个综合性人形机器人框架,支持强化学习策略的训练、部署和动作重定位。该框架兼容多种模拟器(IsaacGym、IsaacSim、MuJoCo等)和机器人(Unitree G1、Booster T1),提供运动控制和全身追踪功能。主要特性包括:跨模拟器训练评估、Wandb集成、多GPU支持、自定义奖励权重和观测噪声配置。推理模块支持实体机器人部署和MuJoCo仿真测试。动作重定位工具可将人体动作数据转换为机器人动作,支持单序列和批量处理。文档详细介绍了训练配置、评估方法和高级功能,如课程学习和

2506_90492529的博客 1828

源码分析:HashMap

大佬讲的贼清晰,看源码清晰多了。 Java:手把手带你源码分析 HashMap 1.7

qq_42956993的博客 112

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

深度学习工具包 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');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: 频繁full gc cpu 100%
下一篇: B树和B+树
九号铅笔芯
博客等级 码龄9年 9粉丝 48原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值