提交 137710c6 编写于 作者: C CyC2018

auto commit

上级 64b26639
<!-- GFM-TOC -->
* [0. 进程内存空间中,堆和栈的区别](#0-进程内存空间中,堆和栈的区别)
<!-- GFM-TOC -->
# 0. 进程内存空间中,堆和栈的区别
> C++
堆:动态、malloc()、new、链式分配、向上生长;栈:函数调用、编译器分配回收、向下生长。
https://www.cnblogs.com/sunziying/p/6510030.html
By @CyC
---
......@@ -70,7 +70,7 @@
接收端能够从消息队列成功消费一次消息。
实现方法:
两种实现方法:
- 保证接收端处理消息的业务逻辑具有幂等性:只要具有幂等性,那么消费多少次消息,最后处理的结果都是一样的。
- 保证消息具有唯一编号,并使用一张日志表来记录已经消费的消息编号。
......
......@@ -58,6 +58,7 @@ public class LRU<K, V> implements Iterable<K> {
}
}
public LRU(int maxSize) {
this.maxSize = maxSize;
......@@ -70,6 +71,7 @@ public class LRU<K, V> implements Iterable<K> {
tail.pre = head;
}
public V get(K key) {
if (!map.containsKey(key)) {
......@@ -83,6 +85,7 @@ public class LRU<K, V> implements Iterable<K> {
return node.v;
}
public void put(K key, V value) {
if (map.containsKey(key)) {
......@@ -100,30 +103,34 @@ public class LRU<K, V> implements Iterable<K> {
}
}
private void unlink(Node node) {
Node pre = node.pre;
node.pre = node.next;
node.next = pre;
Node next = node.next;
pre.next = next;
next.pre = pre;
}
private void appendHead(Node node) {
node.next = head.next;
node.pre = head;
head.next = node;
}
private Node removeTail() {
Node node = tail.pre;
node.pre = tail;
tail.pre = node.pre;
return node;
}
@Override
public Iterator<K> iterator() {
return new Iterator<K>() {
private Node cur = head.next;
@Override
public boolean hasNext() {
return cur != tail;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册