📄 clist.h
字号:
#pragma clist
/* This file contains the declaration of class List.
------------------------------------------------------------------------*/
// IMPLEMENTATION PARAMETERS
typedef double ListElement; // array element type
typedef void *IList;
class List
{
// -- the public section --
public:
/***** Constructors *****/
/* This function is the class constructor for class List.
Precondition: A List object has been declared.
Receive: Len, the length of the array (default 0)
InitVal, the initial value of the array's
elements
Output: An error message if Len > MaxLength
Postcondition: The List has been initialized as a list of
Len elements, each with the value InitVal.
--------------------------------------------------------------*/
void Open(unsigned int Len, ListElement InitVal);
void Close();
/*
Receive: Original, a List object
Return: The object containing this function, with its
members as copies of those of Original, and a
reference to this List (for chained assignments)
----------------------------------------------------------------*/
void Copy(const List& source);
/***---Subscript---
Receive: i, an index for a List element
Return: The value of the element in member Array with index i
----------------------------------------------------------------*/
ListElement I(unsigned int i) const;
/***---Length---
Return: The length of the list (the value stored in field
Length_).
----------------------------------------------------------------*/
unsigned int Length(void) const;
/***---Searches---***/
/***---search ---
Receive: SearchVal, a (ListElement) value
Return: The index of SearchVal, if it is present in
member Array, and -1 otherwise
----------------------------------------------------------------*/
int Search (const ListElement& SearchVal) const;
/***---Find smallest value in a sublist ---
Receive: First, the index of the first element to be examined
Last, the index of the last element to be examined
Last==0 indicates to search from First to last
Return: The index of the smallest value in the examined
elements
----------------------------------------------------------------*/
unsigned int IndexOfMin(unsigned int First, unsigned int Last) const;
/***---Sorts---***/
/***---Sort ---
Return: The List containing this function, its Array
member sorted into 0-ascending order & 1-descending
----------------------------------------------------------------*/
void Sort(unsigned int collate);
void printf(const char format[]) const; //format applies per item
//used to read input; the return value equals one if a value was read
//formats are the same as for printf
int scanf(const char format[]);
/********** data members **********/
IList list;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -