将List转成Map结构,以下为没有水平的写法!
好久之前写的土方法转换,不知道有没有优秀的解法,还希望大家提供!
Map map1 = new HashMap();
map1.put("a", "1");
map1.put("b", "3");
map1.put("c", "5");
Map map2 = new HashMap();...
分类:
其他好文 时间:
2014-05-07 08:35:55
阅读次数:
292
这篇对应的是习题39 字典, 可爱的字典
#encoding:utf-8
#列表与字典的区别
#列表
thing = ['name',1,'age','AD','sex']
print thing[1]
#print thing['name'] #会报错,列表只能通过整数去访问:TypeError: list indices must be integers, not str
stuff...
分类:
编程语言 时间:
2014-05-07 06:00:20
阅读次数:
365
private static void sort1(int x[], int off, int len) {
// Insertion sort on smallest arrays //长度小于7,采用冒泡排序
if (len < 7) {
for (int i=off; ioff && x[j-1]>x[j];...
分类:
其他好文 时间:
2014-05-07 05:14:35
阅读次数:
279
最近在学scala语言,scala代码如下:
import scala.collection.JavaConversions._
object Solution {
def solution(A: Array[Int]): Int = {
// write your code in Scala 2.10
// sort
scala.uti...
分类:
其他好文 时间:
2014-05-07 04:20:38
阅读次数:
352
简单谈谈 Python 中容器的遍历和一下小技巧。
1、遍历单个容器
下面代码遍历一个 List 结构,同样适用于 Tuple、Set 结构类型
>>> x = [1, 2, 3, 'p' , 'y']
>>> for v in x:
... print(x)
...
1
2
3
p
y
遍历字典 Dict 结构也是...
分类:
编程语言 时间:
2014-05-07 04:12:39
阅读次数:
395
下面先来一个网络上的案例,这个案例比较简单,直接在类中进行一些参数的配置,具体代码如下:
package com.wzpmt; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.danga.MemCached.MemCachedClient; impo...
分类:
编程语言 时间:
2014-05-07 03:57:53
阅读次数:
510
package com.array;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import...
分类:
编程语言 时间:
2014-05-07 03:45:11
阅读次数:
365
题目:
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.
Return a deep copy of the list.
思路:
主要是深层复制的问题:
本题比较简...
分类:
其他好文 时间:
2014-05-07 02:44:38
阅读次数:
344
五一中间断了几天,开始继续。。。
1、
??
Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.
Return a...
分类:
其他好文 时间:
2014-05-06 18:54:59
阅读次数:
386
如下图:选择了子数据,默认选中父级数据,数据库中会存储两条数据为使脚本通用性更好,不写死两级,可将数据放到List里处理,代码如下: String
companyName = null; companyName = "测试公司1.1"; stepInfo("校验数据"); DBU...
分类:
其他好文 时间:
2014-05-06 18:14:09
阅读次数:
282