All Downloads are FREE. Search and download functionalities are using the official Maven repository.

shz.core.node.LDNode Maven / Gradle / Ivy

There is a newer version: 2024.0.2
Show newest version
package shz.core.node;

/**
 * 元素类型为E的双向链表节点
 * 

* [24+E(类型字节)+对齐填充]*n(n为元素个数) *

* B=16+24*n+(E+对齐填充)*n */ public class LDNode implements DNode> { private static final long serialVersionUID = -1339865480980259263L; public E val; protected LDNode next; protected LDNode prev; protected LDNode(E val) { this.val = val; } public static LDNode of(E e) { return new LDNode<>(e); } public static LDNode of() { return of(null); } @Override public final LDNode next() { return next; } @Override public final void next(LDNode node) { next = node; } @Override public final LDNode prev() { return prev; } @Override public final void prev(LDNode node) { prev = node; } public final LDNode addNext(E e) { return addNext(of(e)); } @SafeVarargs public final LDNode addNext(E... es) { LDNode next = this; for (E e : es) next = next.addNext(e); return next; } public final LDNode addPrev(E e) { return addPrev(of(e)); } @SafeVarargs public final LDNode addPrev(E... es) { LDNode prev = this; for (E e : es) prev = prev.addPrev(e); return prev; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy