【C++】线性表伪算法

#pragma once
class list
{
private:
	int arrayLength;//最大长度
	int listSize;//实际长度
	int* num;//动态数组
	void checkSize(int index)const;

public:
	list(int initialCapacity = 10);
	list(const list&);
	~list();

	bool empty()const;//判断是否为空
	bool size()const;//返回长度
	int& get(int theIndex)const;
	int indexOf(const int& theElement)const;
	void erase(int theIndex)const;
	void insert(int theIndex, const int& theElement);
	void output()const;//输出
};

void list::checkSize(int index) const
{
	/*
		如果索引小于0或大于等于实际长度
		抛出异常
	*/
}

list::list(int initialCapacity)
{
	/*
	*
	*	如果initialCapacity小于0,
	*	即最大长度小于0,抛出异常
	*
		进行初始化操作
		最大长度 = initialCapacity
		动态数组申请动态内存空间
		有效长度 = 0
	*/
}

list::~list()
{	/*
	删除动态数组
	*/
}

int& list::get(int theIndex) const
{	/*
	判断索引是否正常checkIndex(theIndex)
	*/
	// TODO: 在此处插入 return 语句
}

int list::indexOf(const int& theElement) const
{	/*
	当该数组不存在元素时,返回-1
	*/
	return 0;
}

void list::erase(int theIndex) const
{
	/*
	先判断索引是否正常checkIndex(theIndex)
	*/
}

void list::insert(int theIndex, const int& theElement)
{
	/*
	首先判断索引正常
	如果索引小于0或大于实际长度
	则抛出异常。
	注意:等于实际长度即追加
	*/
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值