示例#1
0
    friend MyList<T> operator + (const MyList<T> &l1, const T &item){
		MyList<T> tmp;
		tmp.n = l1.n + 1;
		int t = tmp.get_SIZE();
		while( t < tmp.n)	
			tmp.double_space();
		tmp[l1.n] = item;
		return tmp;
	} 
示例#2
0
	friend MyList operator + (const MyList &l1, const MyList &l2){
		MyList<T> tmp; int i;
		tmp.n = l1.n + l2.n;
		int t = tmp.get_SIZE();
		while(t < tmp.n)	
			tmp.double_space();
		for (i = 0; i < l1.n; ++i)
			tmp[i] = l1[i];
		for (i = 0; i < l2.n; ++i)
			tmp[i+l1.n] = l2[i];
		return tmp;	
	}
示例#3
0
MyList<T> MyList<T>:: get_item(int start, int end) {
	MyList<T> b;
	try{
	if (start < 0)
		start = n + start;
	if (end < 0)
		end = n + end;
	if (start > end)
		return b;
	if (start > n || end > n || start < 0 || end < 0)
		throw 1;
	int i;
	b.n = end - start + 1;
	while (size < b.n)
		b.double_space();
	for (i = start; i <= end; ++i )
		b.a[i-start] = a[i];
	return b;
	}
	catch(int){
		cout << "List index out of range" << endl;
	}
}