头文件:
#ifndef _SEQLIST_H
#define _SEQLIST_H
#include
#define INIT_SIZE 8
typedef struct SeqList
{
int *base;
size_t size;
size_t capacity;
}SeqList;
// 要实现的函数
void InitList(SeqList *list);...
分类:
编程语言 时间:
2015-05-19 00:47:45
阅读次数:
213
头文件:
#pragma once
#include
using namespace std;
template
class SeqList
{
public:
SeqList(size_t sz = INIT_SIZE);
~SeqList();
public:
bool isfull()const
{
return size > capacity;
}...
分类:
编程语言 时间:
2015-05-18 23:13:33
阅读次数:
132
NSString 是不可变,不能删除或者添加字符。NSString 的子类NSMutableString称为可变字符串创建方法-(id)initWithCapacity:(NSUInteger)capacity+(id)stringWithCapacity:(NSUInteger)capacityc...
分类:
其他好文 时间:
2015-05-18 18:05:01
阅读次数:
222
typedef int Rank; //秩
#define DEFAULT_CAPACITY 3 //默认的初始容量(实际应用中可设置为更大)template class Vector { //向量模板类
protected:
Rank _size; int _capacity; T* _elem; //规模、容量、数据区
void copyFrom(T c...
分类:
其他好文 时间:
2015-05-17 23:40:58
阅读次数:
227
构造函数:// 构造函数
Vector(int c = DEFAULT_CAPACITY, int s = 0, T v = 0) //容量为c、规模为s、所有元素初始为v
{ _elem = new T[_capacity = c]; for (_size = 0; _size < s; _elem[_size++] = v); } //s <= c复制构造函数:从A数组中为[lo,h...
分类:
其他好文 时间:
2015-05-17 23:39:54
阅读次数:
175
1、集合类(增、删、查、改、遍历)a)集合常用操作添加、遍历、移除来自于IList接口b)使用时须先引用命名空间System.Collectionsc)ArrayList可变长度数组,使用类似于数组属性Capacity(容量) Count(实际元素个数)方法Add()AddRange()Remove...
给定指定的一个有向图,其中有两个特殊的点源S(Sources)和汇T(Sinks),每条边有指定的容量(Capacity),求满足条件的从S到T的最大流(MaxFlow).
分类:
编程语言 时间:
2015-05-11 19:29:44
阅读次数:
150
POJ2175 Evacuation Plan 最小费用流 负权消去
The City has a number of municipal buildings and a number of fallout shelters that were build specially to hide municipal workers in case of a nuclear war. Each fallout shelter has a limited capacity in terms of a numbe...
分类:
其他好文 时间:
2015-05-02 09:54:06
阅读次数:
200
当增加新元素(s)时,如果超过当时的容量,则容量会扩充至两倍。如果两倍容量仍不足,就扩张至足够大的容量。
以一个例子来说明:
#include
#include
#include
using namespace std;
int main()
{
int i;
vector iv(2,9);
cout<<"size = "<<iv.size()<<endl;
...
分类:
其他好文 时间:
2015-04-30 09:05:42
阅读次数:
116
ArrayList可以实现容量的自适应的增加,通过阅读源代码,对这个机制进行一下简单的分析。
首先,ArrayList有一个初始的默认大小,为10.
private static final int DEFAULT_CAPACITY = 10;
从add方法为入口
public boolean add(E e) {
ensureCapacityInterna...
分类:
其他好文 时间:
2015-04-29 21:52:39
阅读次数:
216