afpro 最近的时间轴更新
afpro

afpro

V2EX 第 172475 号会员,加入于 2016-05-10 18:35:20 +08:00
afpro 最近回复了
2020-04-01 12:32:43 +08:00
回复了 Achilless 创建的主题 Python tqdm 多行显示问题
我用 cmder 也遇到过这个 尤其是远程桌面进来一次之后 由于远程机器和 windows 本身分辨率不一致 就很容易这样
解决办法有点蠢 出现问题后把 cmder 的窗口拉宽 就好了
只靠大盘数据是不可能赚钱的 你算法再 NB 也没用 洗洗睡吧
如果楼主是做机器学习的 可以了解一下 Julia
2020-03-18 03:09:58 +08:00
回复了 waibunleung 创建的主题 程序员 PHP 转 go 好还是继续深造?
来头条吧 只要能面过 入职之后给时间熟悉 go 内部也有各种技术讲座 完善的新人技术培训
2020-03-13 13:48:29 +08:00
回复了 pOH8 创建的主题 程序员 你们公司都发口罩了吗?
头条还在远程办公 囧
@MatthewHan 你疑惑的是 capacity 这个方法??

final int capacity() {
return (table != null) ? table.length :
(threshold > 0) ? threshold :
DEFAULT_INITIAL_CAPACITY;
}

这不是显然 table 为 null 的时候返回了 threshold 或者 DEFAULT_INITIAL_CAPACITY

有发帖和跟帖的时间瞄一眼 code 可好。。
@MatthewHan 你是没 put 啊 所以只初始化了两个参数 没有 new table 你的疑惑在哪呢??
emmm 我尝试用 ``` 放代码 但是没成功 这个怎么样才能正确的贴代码?
```
public HashMap(int initialCapacity, float loadFactor) {
if (initialCapacity < 0)
throw new IllegalArgumentException("Illegal initial capacity: " +
initialCapacity);
if (initialCapacity > MAXIMUM_CAPACITY)
initialCapacity = MAXIMUM_CAPACITY;
if (loadFactor <= 0 || Float.isNaN(loadFactor))
throw new IllegalArgumentException("Illegal load factor: " +
loadFactor);
this.loadFactor = loadFactor;
this.threshold = tableSizeFor(initialCapacity);
}
```

显然只初始化了一个 float 和一个 int

```
public V put(K key, V value) {
return putVal(hash(key), key, value, false, true);
}

final V putVal(int hash, K key, V value, boolean onlyIfAbsent,
boolean evict) {
Node<K,V>[] tab; Node<K,V> p; int n, i;
if ((tab = table) == null || (n = tab.length) == 0)
n = (tab = resize()).length;
...
}
```

put 的时候如果 (tab = table) == null 会去 resize

```
final Node<K,V>[] resize() {
...
Node<K,V>[] newTab = (Node<K,V>[])new Node[newCap];
...

```

在 resize 里面 new 了新的 table
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5385 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 06:59 · PVG 14:59 · LAX 23:59 · JFK 02:59
Developed with CodeLauncher
♥ Do have faith in what you're doing.