9.2 构造方法
python 中也属于自己的构造函数和析构函数,
class fibs:
def __init__(self):
self.a = 0
self.b = 1
def next(self):
self.a,self.b = self.b,self.a+self.b
return self.a
def __iter__(self):
return sel...
分类:
编程语言 时间:
2014-05-07 05:51:56
阅读次数:
500
[Question]
Given an array of integers, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to t...
分类:
其他好文 时间:
2014-05-07 05:37:44
阅读次数:
278
一 线性表
1.1 数组
1.1.1 Remove Duplicates from Sorted Array
1.1.2 Remove Duplicates from Sorted Array II
1.1.3 Search in Rotated Sorted Array
1.1.4 Search in Rotated Sorted Array II
1.1.5 Median of...
分类:
其他好文 时间:
2014-05-07 04:24:26
阅读次数:
363
最近在学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
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
System.Collections 名称空间中的几个接口提供了基本的组合功能:?
IEnumerable 可以迭代集合中的项。?
ICollection(继承于IEnumerable)可以获取集合中项的个数,并能把项复制到一个简单的数组类型中。? IList(继承于IEnumerable
和ICo...
分类:
其他好文 时间:
2014-05-07 02:16:49
阅读次数:
247
C#部分:1.C#中集合有三种,数组类,ArrayList,和字典键值对类,一般也可以自定义集合,但是自定义集合的类型也只有这三类。2.自定义集合实现三类集合的方法:前两者需要继承CollectionBase类,Array需要使用List属性,ArrayList需要使用InnerList属性,后一种...
分类:
编程语言 时间:
2014-05-07 01:27:42
阅读次数:
396
Python是一种强大的语言,即可浅尝辄止,也可深入挖掘。很适合做科学计算、数据挖掘等等。今天我将简单介绍一下Python的装饰器(Decorators)的用法 。
假设我们想要庆祝下生日,需要邀请一些朋友过来参加。但是你有个讨厌的朋友,叫Joe,必须不能让他来啊。可能首先你想到的是建一个list,然后迭代查找并移除所有的Joe童鞋。这当然是个好方法,但是这里为了介绍装饰器,我们会用@来完成...
分类:
编程语言 时间:
2014-05-06 23:19:53
阅读次数:
371
我们把对象堆起来放成为一个集合,方法有很多,比如放进数组
堆栈
列表中。当客户想要遍历这些对象时,你打算让他看到你的实现么?当然不要!一点专业范儿都没了。
所以今天我们谈的就是如何让客户遍历对象而又无法窥视你存储对象的方式——迭代器模式
概述
提供一种方法顺序访问一个聚合对象中各个元素,而又不暴露该对象的内部表示。
适用情况:当不需要访问一个聚集对象,而且不管这些对象是什么都...
分类:
其他好文 时间:
2014-05-06 23:01:37
阅读次数:
362
Suppose a sorted array is rotated at some pivot unknown to you beforehand.
(i.e., 0 1 2 4 5 6 7 might become 4
5 6 7 0 1 2).
You are given a target value to search. If found in the array retur...
分类:
其他好文 时间:
2014-05-06 19:03:11
阅读次数:
365