In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: If A is a parentnode of B then the key of node A is ordered with respect to the key of node B with the same ordering applying across the heap. Either the keys of parent nodes are always greater than or equal to those of the children and the highest key is in the root node (this kind of heap is called max heap) or the keys of parent nodes are less than or equal to those of the children and the lowest key is in the root node (min heap). Heaps are crucial in several efficient graph algorithms such as Dijkstra's algorithm, and in the sorting algorithm heapsort. A common implementation of a heap is the binary heap, in which the tree is a complete binary tree (see figure).

Heaps are usually implemented in an array, and do not require pointers between elements.

Full and almost full binary heaps may be represented in a very space-efficient way using an array alone. The first (or last) element will contain the root. The next two elements of the array contain its children. The next four contain the four children of the two child nodes, etc. Thus the children of the node at position n would be at positions 2n and 2n+1 in a one-based array, or 2n+1 and 2n+2 in a zero-based array. This allows moving up or down the tree by doing simple index computations. Balancing a heap is done by swapping elements which are out of order. As we can build a heap from an array without requiring extra memory (for the nodes, for example), heapsort can be used to sort an array in-place.

The operations commonly performed with a heap are:

  • create-heap: create an empty heap
  • heapify: create a heap out of given array of elements
  • find-max or find-min: find the maximum item of a max-heap or a minimum item of a min-heap, respectively (aka, peek)
  • delete-max or delete-min: removing the root node of a max- or min-heap, respectively
  • increase-key or decrease-key: updating a key within a max- or min-heap, respectively
  • insert: adding a new key to the heap
  • merge: joining two heaps to form a valid new heap containing all the elements of both.
  • meld(h1,h2): Return the heap formed by taking the union of the item-disjoint heaps h1 and h2. Melding destroys h1 and h2.
  • size: return the number of items in the heap.
  • isEmpty(): returns true if the heap is empty, false otherwise.
  • buildHeap(list): builds a new heap from a list of keys.
  • ExtractMin() [or ExtractMax()]: Returns the node of minimum value from a min heap [or maximum value from a max heap] after removing it from the heap
  • Union(): Creates a new heap by joining two heaps given as input.
  • Shift-up: Move a node up in the tree, as long as needed (depending on the heap condition: min-heap or max-heap)
  • Shift-down: Move a node down in the tree, similar to Shift-up

Different types of heaps implement the operations in different ways, but notably, insertion is often done by adding the new element at the end of the heap in the first available free space. This will tend to violate the heap property, and so the elements are then reordered until the heap property has been reestablished. Construction of a binary (or d-ary) heap out of a given array of elements may be performed faster than a sequence of consecutive insertions into an originally empty heap using the classic Floyd's algorithm, with the worst-case number of comparisons equal to 2N − 2s2(N) − e2(N) (for a binary heap), wheres2(N) is the sum of all digits of the binary representation of N and e2(N) is the exponent of 2 in the prime factorization of N

(reference from:https://en.wikipedia.org/wiki/Heap_(data_structure))

Binary heap

There are several types of heaps, but in the current article we are going to discuss the binary heap. For short, let's call it just "heap". It is used to implement priority queue ADTand in the heapsort algorithm. Heap is a complete binary tree, which answers to the heap property.

http://www.algolist.net/Data_structures/Binary_heap

Implementation in java

路径:commons-collections-3.2.1-src/src/java/org/apache/commons/collections/BinaryHeap.java

  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package org.apache.commons.collections;
  18.  
  19. import java.util.AbstractCollection;
  20. import java.util.Comparator;
  21. import java.util.Iterator;
  22. import java.util.NoSuchElementException;
  23.  
  24. /***
  25. * Binary heap implementation of <code>PriorityQueue</code>.
  26. * <p>
  27. * The <code>PriorityQueue</code> interface has now been replaced for most uses
  28. * by the <code>Buffer</code> interface. This class and the interface are
  29. * retained for backwards compatibility. The intended replacement is
  30. * {@link org.apache.commons.collections.buffer.PriorityBuffer PriorityBuffer}.
  31. * <p>
  32. * The removal order of a binary heap is based on either the natural sort
  33. * order of its elements or a specified {@link Comparator}. The
  34. * {@link #pop()} method always returns the first element as determined
  35. * by the sort order. (The <code>isMinHeap</code> flag in the constructors
  36. * can be used to reverse the sort order, in which case {@link #pop()}
  37. * will always remove the last element.) The removal order is
  38. * <i>not</i> the same as the order of iteration; elements are
  39. * returned by the iterator in no particular order.
  40. * <p>
  41. * The {@link #insert(Object)} and {@link #pop()} operations perform
  42. * in logarithmic time. The {@link #peek()} operation performs in constant
  43. * time. All other operations perform in linear time or worse.
  44. * <p>
  45. * Note that this implementation is not synchronized. Use SynchronizedPriorityQueue
  46. * to provide synchronized access to a <code>BinaryHeap</code>:
  47. *
  48. * <pre>
  49. * PriorityQueue heap = new SynchronizedPriorityQueue(new BinaryHeap());
  50. * </pre>
  51. *
  52. * @deprecated Replaced by PriorityBuffer in buffer subpackage.
  53. * Due to be removed in v4.0.
  54. * @since Commons Collections 1.0
  55. * @version $Revision: 646777 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $
  56. *
  57. * @author Peter Donald
  58. * @author Ram Chidambaram
  59. * @author Michael A. Smith
  60. * @author Paul Jack
  61. * @author Stephen Colebourne
  62. */
  63. public final class BinaryHeap extends AbstractCollection
  64. implements PriorityQueue, Buffer {
  65.  
  66. /***
  67. * The default capacity for a binary heap.
  68. */
  69. private final static int DEFAULT_CAPACITY = 13;
  70. /***
  71. * The number of elements currently in this heap.
  72. */
  73. int m_size; // package scoped for testing
  74. /***
  75. * The elements in this heap.
  76. */
  77. Object[] m_elements; // package scoped for testing
  78. /***
  79. * If true, the first element as determined by the sort order will
  80. * be returned. If false, the last element as determined by the
  81. * sort order will be returned.
  82. */
  83. boolean m_isMinHeap; // package scoped for testing
  84. /***
  85. * The comparator used to order the elements
  86. */
  87. Comparator m_comparator; // package scoped for testing
  88.  
  89. /***
  90. * Constructs a new minimum binary heap.
  91. */
  92. public BinaryHeap() {
  93. this(DEFAULT_CAPACITY, true);
  94. }
  95.  
  96. /***
  97. * Constructs a new <code>BinaryHeap</code> that will use the given
  98. * comparator to order its elements.
  99. *
  100. * @param comparator the comparator used to order the elements, null
  101. * means use natural order
  102. */
  103. public BinaryHeap(Comparator comparator) {
  104. this();
  105. m_comparator = comparator;
  106. }
  107.  
  108. /***
  109. * Constructs a new minimum binary heap with the specified initial capacity.
  110. *
  111. * @param capacity The initial capacity for the heap. This value must
  112. * be greater than zero.
  113. * @throws IllegalArgumentException
  114. * if <code>capacity</code> is &lt;= <code>0</code>
  115. */
  116. public BinaryHeap(int capacity) {
  117. this(capacity, true);
  118. }
  119.  
  120. /***
  121. * Constructs a new <code>BinaryHeap</code>.
  122. *
  123. * @param capacity the initial capacity for the heap
  124. * @param comparator the comparator used to order the elements, null
  125. * means use natural order
  126. * @throws IllegalArgumentException
  127. * if <code>capacity</code> is &lt;= <code>0</code>
  128. */
  129. public BinaryHeap(int capacity, Comparator comparator) {
  130. this(capacity);
  131. m_comparator = comparator;
  132. }
  133.  
  134. /***
  135. * Constructs a new minimum or maximum binary heap
  136. *
  137. * @param isMinHeap if <code>true</code> the heap is created as a
  138. * minimum heap; otherwise, the heap is created as a maximum heap
  139. */
  140. public BinaryHeap(boolean isMinHeap) {
  141. this(DEFAULT_CAPACITY, isMinHeap);
  142. }
  143.  
  144. /***
  145. * Constructs a new <code>BinaryHeap</code>.
  146. *
  147. * @param isMinHeap true to use the order imposed by the given
  148. * comparator; false to reverse that order
  149. * @param comparator the comparator used to order the elements, null
  150. * means use natural order
  151. */
  152. public BinaryHeap(boolean isMinHeap, Comparator comparator) {
  153. this(isMinHeap);
  154. m_comparator = comparator;
  155. }
  156.  
  157. /***
  158. * Constructs a new minimum or maximum binary heap with the specified
  159. * initial capacity.
  160. *
  161. * @param capacity the initial capacity for the heap. This value must
  162. * be greater than zero.
  163. * @param isMinHeap if <code>true</code> the heap is created as a
  164. * minimum heap; otherwise, the heap is created as a maximum heap.
  165. * @throws IllegalArgumentException
  166. * if <code>capacity</code> is <code>&lt;= 0</code>
  167. */
  168. public BinaryHeap(int capacity, boolean isMinHeap) {
  169. if (capacity <= 0) {
  170. throw new IllegalArgumentException("invalid capacity");
  171. }
  172. m_isMinHeap = isMinHeap;
  173.  
  174. //+1 as 0 is noop
  175. m_elements = new Object[capacity + 1];
  176. }
  177.  
  178. /***
  179. * Constructs a new <code>BinaryHeap</code>.
  180. *
  181. * @param capacity the initial capacity for the heap
  182. * @param isMinHeap true to use the order imposed by the given
  183. * comparator; false to reverse that order
  184. * @param comparator the comparator used to order the elements, null
  185. * means use natural order
  186. * @throws IllegalArgumentException
  187. * if <code>capacity</code> is <code>&lt;= 0</code>
  188. */
  189. public BinaryHeap(int capacity, boolean isMinHeap, Comparator comparator) {
  190. this(capacity, isMinHeap);
  191. m_comparator = comparator;
  192. }
  193.  
  194. //-----------------------------------------------------------------------
  195. /***
  196. * Clears all elements from queue.
  197. */
  198. public void clear() {
  199. m_elements = new Object[m_elements.length]; // for gc
  200. m_size = 0;
  201. }
  202.  
  203. /***
  204. * Tests if queue is empty.
  205. *
  206. * @return <code>true</code> if queue is empty; <code>false</code>
  207. * otherwise.
  208. */
  209. public boolean isEmpty() {
  210. return m_size == 0;
  211. }
  212.  
  213. /***
  214. * Tests if queue is full.
  215. *
  216. * @return <code>true</code> if queue is full; <code>false</code>
  217. * otherwise.
  218. */
  219. public boolean isFull() {
  220. //+1 as element 0 is noop
  221. return m_elements.length == m_size + 1;
  222. }
  223.  
  224. /***
  225. * Inserts an element into queue.
  226. *
  227. * @param element the element to be inserted
  228. */
  229. public void insert(Object element) {
  230. if (isFull()) {
  231. grow();
  232. }
  233. //percolate element to it's place in tree
  234. if (m_isMinHeap) {
  235. percolateUpMinHeap(element);
  236. } else {
  237. percolateUpMaxHeap(element);
  238. }
  239. }
  240.  
  241. /***
  242. * Returns the element on top of heap but don't remove it.
  243. *
  244. * @return the element at top of heap
  245. * @throws NoSuchElementException if <code>isEmpty() == true</code>
  246. */
  247. public Object peek() throws NoSuchElementException {
  248. if (isEmpty()) {
  249. throw new NoSuchElementException();
  250. } else {
  251. return m_elements[1];
  252. }
  253. }
  254.  
  255. /***
  256. * Returns the element on top of heap and remove it.
  257. *
  258. * @return the element at top of heap
  259. * @throws NoSuchElementException if <code>isEmpty() == true</code>
  260. */
  261. public Object pop() throws NoSuchElementException {
  262. final Object result = peek();
  263. m_elements[1] = m_elements[m_size--];
  264.  
  265. // set the unused element to 'null' so that the garbage collector
  266. // can free the object if not used anywhere else.(remove reference)
  267. m_elements[m_size + 1] = null;
  268.  
  269. if (m_size != 0) {
  270. // percolate top element to it's place in tree
  271. if (m_isMinHeap) {
  272. percolateDownMinHeap(1);
  273. } else {
  274. percolateDownMaxHeap(1);
  275. }
  276. }
  277.  
  278. return result;
  279. }
  280.  
  281. /***
  282. * Percolates element down heap from the position given by the index.
  283. * <p>
  284. * Assumes it is a minimum heap.
  285. *
  286. * @param index the index for the element
  287. */
  288. protected void percolateDownMinHeap(final int index) {
  289. final Object element = m_elements[index];
  290. int hole = index;
  291.  
  292. while ((hole * 2) <= m_size) {
  293. int child = hole * 2;
  294.  
  295. // if we have a right child and that child can not be percolated
  296. // up then move onto other child
  297. if (child != m_size && compare(m_elements[child + 1], m_elements[child]) < 0) {
  298. child++;
  299. }
  300.  
  301. // if we found resting place of bubble then terminate search
  302. if (compare(m_elements[child], element) >= 0) {
  303. break;
  304. }
  305.  
  306. m_elements[hole] = m_elements[child];
  307. hole = child;
  308. }
  309.  
  310. m_elements[hole] = element;
  311. }
  312.  
  313. /***
  314. * Percolates element down heap from the position given by the index.
  315. * <p>
  316. * Assumes it is a maximum heap.
  317. *
  318. * @param index the index of the element
  319. */
  320. protected void percolateDownMaxHeap(final int index) {
  321. final Object element = m_elements[index];
  322. int hole = index;
  323.  
  324. while ((hole * 2) <= m_size) {
  325. int child = hole * 2;
  326.  
  327. // if we have a right child and that child can not be percolated
  328. // up then move onto other child
  329. if (child != m_size && compare(m_elements[child + 1], m_elements[child]) > 0) {
  330. child++;
  331. }
  332.  
  333. // if we found resting place of bubble then terminate search
  334. if (compare(m_elements[child], element) <= 0) {
  335. break;
  336. }
  337.  
  338. m_elements[hole] = m_elements[child];
  339. hole = child;
  340. }
  341.  
  342. m_elements[hole] = element;
  343. }
  344.  
  345. /***
  346. * Percolates element up heap from the position given by the index.
  347. * <p>
  348. * Assumes it is a minimum heap.
  349. *
  350. * @param index the index of the element to be percolated up
  351. */
  352. protected void percolateUpMinHeap(final int index) {
  353. int hole = index;
  354. Object element = m_elements[hole];
  355. while (hole > 1 && compare(element, m_elements[hole / 2]) < 0) {
  356. // save element that is being pushed down
  357. // as the element "bubble" is percolated up
  358. final int next = hole / 2;
  359. m_elements[hole] = m_elements[next];
  360. hole = next;
  361. }
  362. m_elements[hole] = element;
  363. }
  364.  
  365. /***
  366. * Percolates a new element up heap from the bottom.
  367. * <p>
  368. * Assumes it is a minimum heap.
  369. *
  370. * @param element the element
  371. */
  372. protected void percolateUpMinHeap(final Object element) {
  373. m_elements[++m_size] = element;
  374. percolateUpMinHeap(m_size);
  375. }
  376.  
  377. /***
  378. * Percolates element up heap from from the position given by the index.
  379. * <p>
  380. * Assume it is a maximum heap.
  381. *
  382. * @param index the index of the element to be percolated up
  383. */
  384. protected void percolateUpMaxHeap(final int index) {
  385. int hole = index;
  386. Object element = m_elements[hole];
  387.  
  388. while (hole > 1 && compare(element, m_elements[hole / 2]) > 0) {
  389. // save element that is being pushed down
  390. // as the element "bubble" is percolated up
  391. final int next = hole / 2;
  392. m_elements[hole] = m_elements[next];
  393. hole = next;
  394. }
  395.  
  396. m_elements[hole] = element;
  397. }
  398.  
  399. /***
  400. * Percolates a new element up heap from the bottom.
  401. * <p>
  402. * Assume it is a maximum heap.
  403. *
  404. * @param element the element
  405. */
  406. protected void percolateUpMaxHeap(final Object element) {
  407. m_elements[++m_size] = element;
  408. percolateUpMaxHeap(m_size);
  409. }
  410.  
  411. /***
  412. * Compares two objects using the comparator if specified, or the
  413. * natural order otherwise.
  414. *
  415. * @param a the first object
  416. * @param b the second object
  417. * @return -ve if a less than b, 0 if they are equal, +ve if a greater than b
  418. */
  419. private int compare(Object a, Object b) {
  420. if (m_comparator != null) {
  421. return m_comparator.compare(a, b);
  422. } else {
  423. return ((Comparable) a).compareTo(b);
  424. }
  425. }
  426.  
  427. /***
  428. * Increases the size of the heap to support additional elements
  429. */
  430. protected void grow() {
  431. final Object[] elements = new Object[m_elements.length * 2];
  432. System.arraycopy(m_elements, 0, elements, 0, m_elements.length);
  433. m_elements = elements;
  434. }
  435.  
  436. /***
  437. * Returns a string representation of this heap. The returned string
  438. * is similar to those produced by standard JDK collections.
  439. *
  440. * @return a string representation of this heap
  441. */
  442. public String toString() {
  443. final StringBuffer sb = new StringBuffer();
  444.  
  445. sb.append("[ ");
  446.  
  447. for (int i = 1; i < m_size + 1; i++) {
  448. if (i != 1) {
  449. sb.append(", ");
  450. }
  451. sb.append(m_elements[i]);
  452. }
  453.  
  454. sb.append(" ]");
  455.  
  456. return sb.toString();
  457. }
  458.  
  459. /***
  460. * Returns an iterator over this heap's elements.
  461. *
  462. * @return an iterator over this heap's elements
  463. */
  464. public Iterator iterator() {
  465. return new Iterator() {
  466.  
  467. private int index = 1;
  468. private int lastReturnedIndex = -1;
  469.  
  470. public boolean hasNext() {
  471. return index <= m_size;
  472. }
  473.  
  474. public Object next() {
  475. if (!hasNext()) throw new NoSuchElementException();
  476. lastReturnedIndex = index;
  477. index++;
  478. return m_elements[lastReturnedIndex];
  479. }
  480.  
  481. public void remove() {
  482. if (lastReturnedIndex == -1) {
  483. throw new IllegalStateException();
  484. }
  485. m_elements[ lastReturnedIndex ] = m_elements[ m_size ];
  486. m_elements[ m_size ] = null;
  487. m_size--;
  488. if( m_size != 0 && lastReturnedIndex <= m_size) {
  489. int compareToParent = 0;
  490. if (lastReturnedIndex > 1) {
  491. compareToParent = compare(m_elements[lastReturnedIndex],
  492. m_elements[lastReturnedIndex / 2]);
  493. }
  494. if (m_isMinHeap) {
  495. if (lastReturnedIndex > 1 && compareToParent < 0) {
  496. percolateUpMinHeap(lastReturnedIndex);
  497. } else {
  498. percolateDownMinHeap(lastReturnedIndex);
  499. }
  500. } else { // max heap
  501. if (lastReturnedIndex > 1 && compareToParent > 0) {
  502. percolateUpMaxHeap(lastReturnedIndex);
  503. } else {
  504. percolateDownMaxHeap(lastReturnedIndex);
  505. }
  506. }
  507. }
  508. index--;
  509. lastReturnedIndex = -1;
  510. }
  511.  
  512. };
  513. }
  514.  
  515. /***
  516. * Adds an object to this heap. Same as {@link #insert(Object)}.
  517. *
  518. * @param object the object to add
  519. * @return true, always
  520. */
  521. public boolean add(Object object) {
  522. insert(object);
  523. return true;
  524. }
  525.  
  526. /***
  527. * Returns the priority element. Same as {@link #peek()}.
  528. *
  529. * @return the priority element
  530. * @throws BufferUnderflowException if this heap is empty
  531. */
  532. public Object get() {
  533. try {
  534. return peek();
  535. } catch (NoSuchElementException e) {
  536. throw new BufferUnderflowException();
  537. }
  538. }
  539.  
  540. /***
  541. * Removes the priority element. Same as {@link #pop()}.
  542. *
  543. * @return the removed priority element
  544. * @throws BufferUnderflowException if this heap is empty
  545. */
  546. public Object remove() {
  547. try {
  548. return pop();
  549. } catch (NoSuchElementException e) {
  550. throw new BufferUnderflowException();
  551. }
  552. }
  553.  
  554. /***
  555. * Returns the number of elements in this heap.
  556. *
  557. * @return the number of elements in this heap
  558. */
  559. public int size() {
  560. return m_size;
  561. }
  562.  
  563. }

binary heap的更多相关文章

  1. 堆(Heap)和二叉堆(Binary heap)

    堆(Heap) The operations commonly performed with a heap are: create-heap: create an empty heap heapify ...

  2. C++之Binary Heap/Max Heap

    #include <iostream> #include <time.h> #include <random> using namespace std; //Bin ...

  3. [Swift]有用的Binary Heap Type类

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  4. 二叉堆(binary heap)

    堆(heap) 亦被称为:优先队列(priority queue),是计算机科学中一类特殊的数据结构的统称.堆通常是一个可以被看做一棵树的数组对象.在队列中,调度程序反复提取队列中第一个作业并运行,因 ...

  5. Binary Heap(二叉堆) - 堆排序

    这篇的主题主要是Heapsort(堆排序),下一篇ADT数据结构随笔再谈谈 - 优先队列(堆). 首先,我们先来了解一点与堆相关的东西.堆可以实现优先队列(Priority Queue),看到队列,我 ...

  6. 二叉堆(binary heap)—— 优先队列的实现

    二叉堆因为对应着一棵完全二叉树,因而可以通过线性数组的方式实现. 注意,数组第 0 个位置上的元素,作为根,还是第 1 个位置上的元素作为根? 本文给出的实现,以数组第 1 个位置上的元素作为根,则其 ...

  7. 纸上谈兵:左倾堆(leftist heap)

    作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 我们之前讲解了堆(heap)的概念.堆是一个优先队列.每次从堆中取出的元素都是堆中 ...

  8. 纸上谈兵:堆(heap)

    作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 堆(heap)又被为优先队列(priority queue).尽管名为优先队列,但 ...

  9. Erlang数据类型的表示和实现(5)——binary

    binary 是 Erlang 中一个具有特色的数据结构,用于处理大块的“原始的”字节块.如果没有 binary 这种数据类型,在 Erlang 中处理字节流的话可能还需要像列表或元组这样的数据结构. ...

随机推荐

  1. bzoj 3242: [Noi2013]快餐店 章鱼图

    3242: [Noi2013]快餐店 Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 266  Solved: 140[Submit][Status] ...

  2. 教你如何监控 Apache?

    什么是 Apache? Apache 是一款 HTTP 服务器软件,现在更名为 "http",而 Apache 则成了一个(包含httpd的项目)巨大的基金组织,根据习惯后文都用 ...

  3. Gartner 如何看 RASP 和 WAF?

    在这个计算机网络飞速发展的网络时代里,新兴的网络威胁正在不断「侵蚀」着的应用程序和核心数据的安全,各种繁杂的防护手段也随之接踵而来.众所周知,Gartner 是全球最具权威的 IT 研究与顾问咨询公司 ...

  4. 高人ozhy111提供的下载资源

    特别是有很多手机方面的独创源代码,先记下来,有空挨个看一遍: http://download.csdn.net/user/ozhy111 比如:idtcpserver文件传输xe7PC端及手机端 ht ...

  5. 手机归属地查询-IP地址查询-身份证查询-域名备案查询--Api接口

    使用这些接口是需要密钥的 公共密钥 appkey: 10003  secret: d1149a30182aa2088ef645309ea193bf  生成后sign: b59bc3ef6191eb9f ...

  6. java 常量池

    在jvm规范中,每个类型都有自己的常量池.常量池是某类型所用常量的一个有序集合,包括直接常量(基本类型,String)和对其他类型.字段.方法的符号引用.之所以是符号引用而不是像c语言那样,编译时直接 ...

  7. 【HDOJ】4585 Shaolin

    Set可解,Treap也可解.(1) Treap /* */ #include <iostream> #include <string> #include <map> ...

  8. SharePoint 2010中使用Visual Studio 2010进行方便快速的Web Part开发

    转:http://www.cnblogs.com/fatwhale/archive/2010/02/24/1672633.html 在Visual Studio 2010中,  已经集成了用于Shar ...

  9. HDU- Who Gets the Most Candies?

    Who Gets the Most Candies? Time Limit : 10000/5000ms (Java/Other)   Memory Limit : 262144/131072K (J ...

  10. 字符串编码、Base64字符串 互转

    /// <summary>  /// 将字符串编码为Base64字符串  /// </summary>  /// <param name="str"& ...