1.stable_sort 和 sort的区别在于 前者作排序可以使原来的"相同"的值在序列中的相对位置不变
如 1 4 6 7 4' (4 和 4'值相等,加上' 表示是2个元素)
那么stable_sort能保证排序完 4 仍然在4' 前 也就是输出1 4 4' 6 7;但是sort 没有这个功能,算法不能保证这一点
2.在标准算法中的一部分算法 如果这个算法默认使用的是
...
分类:
其他好文 时间:
2014-04-29 13:45:20
阅读次数:
273
Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…
You must do this in-place without altering the nodes' values.
For example,
Given {1,2,3,4}, reorder it to ...
分类:
其他好文 时间:
2014-04-29 13:42:21
阅读次数:
427
有一个需要,给定一个数组,从中生成要求个数的随机数组,不重复,即getRandomArray(int[] originalArray,int number) 这样的一个函数。想了一下,可以这样做:
把数组元素放到一个List中从List中随机取一个数把取到的数从List中删除重复上述过程
代码如下:
import java.util.ArrayList;
import java.ut...
分类:
其他好文 时间:
2014-04-29 13:41:20
阅读次数:
295
JsonTools
package com.example.weather_json.tools;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import co...
分类:
Web程序 时间:
2014-04-29 13:37:21
阅读次数:
1039
JSP页面:
listValue="name" key="name" cssStyle="width:130px">
后台:
private List navs;
navs=navservice.allNav();调用dao层取得所有的值集合。
注: listValue="name"通过设置这个属性显示所有的select内容...
分类:
其他好文 时间:
2014-04-29 13:32:23
阅读次数:
236
使用函数操作链表
1:计算链表中结点的个数:定义一个Length_list()函数用于计算链表中结点的个数
函数代码:
//计算链表中结点的个数
void Length_list(PNODE pHead)
{
PNODE p = pHead->pNext;
int len = 0;
while(NULL != p)
{
len++;
p = p->pNext;
...
分类:
其他好文 时间:
2014-04-29 13:28:21
阅读次数:
302
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
...
分类:
其他好文 时间:
2014-04-29 13:28:21
阅读次数:
398
泛型的Binary Search Tree的实现,并与STL map进行操作性能上的比较...
分类:
其他好文 时间:
2014-04-29 13:27:22
阅读次数:
420
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
...
分类:
其他好文 时间:
2014-04-29 13:13:21
阅读次数:
309
利用内存chunk充当数据buffer的vector的实现,和STL vector 有接口操作性能比较...
分类:
其他好文 时间:
2014-04-29 13:11:20
阅读次数:
318