数据排序方法 原地排序sort()方法 复制排序sorted()函数
分类:
编程语言 时间:
2014-05-24 06:40:44
阅读次数:
215
pthread_join 函数是会阻塞主线程的,这会让很多java程序员不适应。因为在java中
start以后一个线程就执行执行了。主线程不会被阻塞。而在linux中 join是会阻塞的。那么如何使用join的时候
不阻塞主线程呢。我给出了一个解决方法。#include #include void...
分类:
编程语言 时间:
2014-05-24 05:59:40
阅读次数:
571
当我们仅仅需要a+b 的时候,两个字符串链接任何方法的效率基本一样,都在0.0001毫秒内就可以完成。不过如果需要1万次,10000万次,就会发现string自身的join速度显著下降
package com.java.lang;
public class StringTest {
int MAX = 10000; //1万次累加
public String Buffer(){...
分类:
编程语言 时间:
2014-05-22 13:35:23
阅读次数:
299
问题描述
对一个单链表进行插入排序,head指向第一个结点。
代码
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/...
分类:
其他好文 时间:
2014-05-22 10:15:43
阅读次数:
233
1.在没有设置默认值的情况下:
SELECT userinfo.id, user_name, role, adm_regionid, region_name , create_time
FROM userinfo
LEFT JOIN region ON userinfo.adm_regionid = region.id
结果:
设置显示默认值:
SELECT userinfo.id, u...
分类:
数据库 时间:
2014-05-22 08:09:29
阅读次数:
418
1.统计/usr/bin目录下的文件个数[root@localhost~]#ls/usr/bin|wc-l
1306
[root@localhost~]#2.取出当前系统上所有用户的SHELL,要求,每种SHELL只显示一次,并且按顺序进行显示[root@localhost~]#cut-d:-f7/etc/passwd|sort-u
/bin/bash
/bin/nologin
/bin/sync
/bin/tcsh
/sb..
分类:
系统相关 时间:
2014-05-21 02:01:09
阅读次数:
530
最近写代码,无意中发现了一个坑,关于自定义比较函数的stl
sort函数的坑,于是记录下来。先贴代码: 1 #include 2 #include 3 #include 4 5 struct finder 6 { 7
bool operator()(int first, in...
分类:
其他好文 时间:
2014-05-19 14:47:48
阅读次数:
319
例如:有表1,表2两张相,希望通过like进行关联查询
// mysql中使用concat连接字符串
select t1.id, t1.title, t2.keyword from t1 inner join t2 on t1.title like concat('%', t2.keyword, '%');
// oracle、postgres 使用||连接字符串,其它库使用...
分类:
其他好文 时间:
2014-05-18 15:57:36
阅读次数:
242
能使用STL的sort系列算法的前提是容器的迭代器必须为随机迭代器。所以,vector和deque天然适用。STL的sort算法采用了一些策略,在不同情况下采用不同的排序算法,以达到各种算法优势互补的效果。基本的原则是:数据量大时采用快速排序,数据量小时采用插入排序(这是对快排常用的一种优化策略),递归层次过深改用堆排序。
首先是插入排序。它的平均和最坏时间复杂度都为O(N²),量级小于...
分类:
其他好文 时间:
2014-05-18 14:40:31
阅读次数:
241
1. 写法轻松,更新效率高:
update table1
set field1=table2.field1,
field2=table2.field2
from table2
where table1.id=table2.id
2. 常规方式,种写法相当于一个 Left join, 以外面的where为更新条数,如果不加where就是所有记录
update table1
s...
分类:
数据库 时间:
2014-05-18 06:05:00
阅读次数:
294