自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(12)
  • 收藏
  • 关注

原创 自定义实现RandomPool

public class RandomPool<T> { /** * 设计一种结构,在该结构中有如下三个功能 * insert(key): 将某个key加入到该结构,做到不重复加入 * delete(key):将原本在结构中的某个key移除 * getRadom():等概率随机返回结构中的任何一个key */ Map<Integer,T> dataMap; Map<T,Integer> dataK;...

2020-12-11 13:47:04 102

原创 LFU缓存设计实现

public class LFUcacheTest { /** * 一个缓存结构需要实现如下功能 * void set(key,value) 加入或修改key对应的value * int get(key) 查询对应的value的值 * 缓存中最多放K条记录,如果新的第K+1条记录加入,就需要根据策略删掉一条记录,然后把新记录加入 * 策略:在缓存结构的K条记录中,哪一个key从进入缓存结构的时刻开始,被调用set或get的次数最少,就删掉这个key记...

2020-12-10 16:18:03 292

原创 LRU缓存删除最不经常使用的记录

/** * 设计LRU缓存结构,该结构在构造时确定大小,假设大小为K,并有如下两个功能 * set(key,value) * get(key) * 某个key的set或get一旦发生,认为这个key的记录是最常用的 * 当缓存的大小超过K,移除最不经常使用的记录,即set或get最久远的 * */ public static void main(String[] args) { // TODO Auto-gene...

2020-12-09 17:22:29 148

原创 自定义简单定时job

public class ThreadPool { private final static ExecutorService es = Executors.newCachedThreadPool(); public static ExecutorService getExecutor() { return es; } } public class MyJob { //间隔秒数 public static void startJo...

2020-11-13 09:48:46 104

原创 链表实现二叉树,获取二叉树高度

/* * 自定义二叉树 */ public class Tree { Node<Integer> head;//二叉树头 public void add(Integer value) { Node<Integer> node = new Node<>(value); if(head == null) { head = node; }else { ...

2020-10-28 16:46:25 204

原创 利用两个链表做相加算法

public class LinkList<T> { Node<T> head; Node<T> tail; Node<T> pre; Node<T> next; //头部添加 public void addFirst(T value) { Node<T> node = new Node<>(value); if(head == nul...

2020-10-27 15:12:25 278

原创 链表排序(添加排序/手动排序)

public class LinkSort { /* * 链表排序 使链表保持 1、2、3、4、5 */ public static void main(String[] args) { LinkedSort<Integer> linkedSort = new LinkedSort<>(); linkedSort.addFirst(1); linkedSort.addFirst(5)...

2020-10-22 19:26:06 77

原创 删除链表中间元素

/* * 作为自定义链表公共类 */ public class Node<T> { T value; Node<T> pre; Node<T> next; public Node(T value){ this.value = value; } } public class DeleteMiddle { /** * 删除链表中间节点 */ public st...

2020-10-22 14:49:45 160

原创 前缀树实现(模糊查询)

public class PrefixTree { /* * 前缀树:以26位字母作为前缀树 */ Node<Character > head = new Node<>(); public static void main(String[] args) { PrefixTree prefixTree = new PrefixTree(); prefixTree.insert("abcdef"); ...

2020-10-17 02:55:56 558

原创 数组实现完全二叉树(大根堆)

public class AvlTree { /* * 堆结构就是用数组实现的完全二叉树结构 * 完全二叉树中如果每棵子树的最大值都在顶部就是大根堆 * 完全二叉树中如果每棵子树的最小值都在顶部就是小根堆 * 优先级队列结构就是堆结构 * * 数组实现完全二叉树(大根堆) * 数组从1开始存储 [null,9,5,6,4,3] * 父:i 左子节点:2*i 右子节点:2*i+1 */ int[] ar...

2020-10-14 14:12:02 1267 1

原创 数组实现栈和队列

public class ArrayAsStackAndQueue { /* * 数组实现栈和队列 */ public static void main(String[] args) { MyArray myArr = new MyArray(); //栈实现 for(int i =0;i<15;i++) { myArr.push(i); } for(int i...

2020-10-12 18:50:07 100

原创 双向链表实现队列和栈

/* * 作为自定义链表公共类 */ public class Node<T> { T value; Node<T> pre; Node<T> next; public Node(T value){ this.value = value; } } public class SelfStackAndQueue { /* * 用双向链表实现队列和栈 */ publi...

2020-10-12 16:29:07 158

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除