当前位置:网站首页>Simple manual implementation of map
Simple manual implementation of map
2022-07-27 21:32:00 【Ghost punishment OLO】
package redisprc.test;
import java.util.*;
/** * @Author lijiaxin * @Description TODO * @Date 2022/07/27/15:55 * @Version 1.0 */
public class myMap<K, V> {
private Node<K,V>[] nodes;
private int size;
private static class Node<K,V> {
K key;
V value;
Node(K key,V value){
this.key = key;
this.value = value;
}
}
public void put(K key,V value){
if(nodes == null){
nodes = new Node[10];
}
int index = indexOfkey(key);
if (index!=-1){
nodes[index].value = value;
}else {
nodes[size] = new Node<K, V>(key,value);
size++;
}
}
private int indexOfkey(K key){
for (int index = 0; index < size; index++) {
if (key.equals(this.nodes[index].key)){
return index;
}
}
return -1;
}
public V get(K key){
int index = indexOfkey(key);
if (index!=-1){
return nodes[index].value;
}
return null;
}
public int size(){
return size;
}
}
边栏推荐
- Principle analysis and best practice of guava cache
- 美司法部增加针对华为的指控,包括窃取商业秘密等16项新罪名
- mysql 最大建议行数2000w,靠谱吗?
- Mysql 回表、SQL优化、四种隔离级别、三大日志binlog、redo log、undo log
- 飞桨框架体验评测交流会,产品的使用体验由你来决定!
- How to check whether there is Tsinghua source / delete Tsinghua source and keep the default source
- Zibbix installation and deployment
- 纳微半导体65W 氮化镓(GaN)方案获小米10 Pro充电器采用
- 30分钟彻底弄懂 synchronized 锁升级过程
- “地理-语言”大模型文心ERNIE-GeoL及应用
猜你喜欢

Some operations about Anaconda (installing software and quickly opening)
![[2022 Niuke multi School Game 2] k-link with bracket sequence I](/img/95/9d6710bfb7b9282b4a06a5f61a1f08.png)
[2022 Niuke multi School Game 2] k-link with bracket sequence I

University of Tilburg, Federal University of the Netherlands | neural data to text generation based on small datasets: comparing the added value of two semi supervised learning approvals on top of a l

Worthington磷脂酶A2研究丨磷脂酰胆碱2-乙酰水解酶

新来个技术总监要我做一个 IP 属地功能~

"Geography language" large model Wenxin Ernie geol and its application

MySQL back to table, SQL optimization, four isolation levels, three logs binlog, redo log, undo log

ADB shell LS /system/bin (index table)

Report design - how to make your powerbi Kanban brilliant?

Guava Cache 原理分析与最佳实践
随机推荐
Technical practice behind bloom model: how to refine 176billion parameter model?
Rust variable characteristics
Good driving, inexpensive, comfortable and safe! Experience BYD song Pro DM-I in depth
Understanding of reg type variables in Verilog HDL
Knife4j dynamically refreshes global parameters through JS
Pytest失败重跑
【2022牛客多校第二场】K-Link with Bracket Sequence I
华为成立全球生态发展部:全力推进HMS全球生态建设
The new CTO strongly prohibits the use of calendar?
LinkedList underlying source code
xml编写补间动画 PopupWindow实现出现退出的动画
Yyds dry inventory learn how to write function overloads in typescript
【华为HCIE安全考什么科目?华为HCIE安全考什么知识点?】
新来CTO 强烈禁止使用Calendar...,那用啥?
[anti shake and throttling]
Design of noise reduction link based on DSP
Characteristics and determination scheme of Worthington mushroom polyphenol oxidase
简单手动实现Map
Thinking about SLA of cloud computing
LM NAV: robot navigation method based on large models of language, vision and behavior