⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vector.h

📁 图像处理的压缩算法
💻 H
📖 第 1 页 / 共 5 页
字号:
			vector<int> vI(10);    // vector of 10 ints
		Parameters:
			nSize=Size of declared vector
	*/
	vector(UINT nSize); // Constructor to create a vector having size nSize.

	/**
			Constructor to create a vector copy of an Origin Dataset. Missing values may or may
			not be removed.
		Example:
			Dataset dsB("Data1_B");      // Origin data set Data1_B must exist
			dsB.SetSize(5);              // Set sizeof data set to 5          
			dsB[0]=-1;
			dsB[1]=5;
			dsB[2]=NANUM;                // Will be removed
			dsB[3]=NANUM;                // Will be removed
			dsB[4]=23;
			vector vB( dsB, TRUE );      // Copy Dataset dsD to vector vD removing missing values
			ASSERT( vB.GetSize() == 3 ); // Elements dsB[2] and dsB[3] are removed 
		Parameters:
			nSize=Size of declared vector
		SeeAlso:
			Dataset::TrimLeft, Dataset::TrimRight
	*/
	vector(Dataset &ds, BOOL bRemoveMissingValues = FALSE); // Constructor to create a vector copy of an Origin Dataset.
	
#if  _OC_VER > 0x0703
	/**#
			Constructor to create a vector from a Column. The vector is intialized by copying
			the contents of the column between nLowerIndex and nUpperIndex into the vector.
			On exit from the scope where the vector is declared, depending on the value
			of nWriteback used as construction time, the values from the vector are written
			back into the column.
		Example:
			// Have some data in the second column of worksheet "Data1" before running this example.
			int	test_column_writeback()
			{
				Column		col("Data1", 1);
				vector		v(col, 2, 5, WRITEBACK_DELETE_ON_SHRINK | WRITEBACK_INSERT_ON_EXPAND);
				
				// Dump the source range
				int			nSrcLowerIndex, nSrcUpperIndex;
				if (v.GetSourceRange(nSrcLowerIndex, nSrcUpperIndex))
					printf("nSrcLowerIndex = %ld\tnSrcUpperIndex = %ld\n", nSrcLowerIndex, nSrcUpperIndex);
				
				// Modify the vector:
				int			nNewVectorSize = 80;
				v.SetSize(nNewVectorSize);
				for (int ii = 0; ii < nNewVectorSize; ii++)
				{
					v[ii] = 100 * (ii + 1);
				}

				return 0;
			} 
		Parameters:
			cc=source column (it must be initialized properly prior to calling the constructor).
			nLowerIndex=the start index inside the column from which the copying should start;
						if -1, the constructor scans from the beginning of the dataset until it
						finds the first nonmissing value. The value is remembered and can be accessed
						using the method GetSourceRange().
			nUpperIndex=the end index inside the column where the copying should end;
						if -1, the constructor scans from the end of the dataset until it
						finds the first nonmissing value. The value is remembered and can be accessed
						using the method GetSourceRange().
			nWriteback=the combination of values from enumeration:
						enum {
							WRITEBACK_NO = 0,				// no writeback
							WRITEBACK_NO_RESIZE = 0x1,		// writes back the vector without resizing or
															// moving the data inside the column (not that both
															// the vector and the column may have been resized
															// between the construction and the writeback time).
							WRITEBACK_INSERT_ON_EXPAND = 0x2,	// not used if WRITEBACK_NO_RESIZE bit is present;
																// if the vector has increased in size after the
																// construction, on writeback the column will be
																// expanded to accomodate additional values, all of
																// which are going to be inserted after m_nSrcUpperIndex
																// and any data (if) already present in the column,
																// will be pushed to the right.
							WRITEBACK_DELETE_ON_SHRINK = 0x8,	// not used if WRITEBACK_NO_RESIZE bit is present; 
																// if the vector has decreased in size after the
																// construction, on writeback the column will be
																// shrunk for the size change, and any data (if present)
																// that were to the right of m_nSrcUpperIndex 
																// will be pushed to the left.
						};

	*/
	vector(Column& cc, int nLowerIndex = -1, int nUpperIndex = -1, int nWriteback = WRITEBACK_NO);
#endif //#if  _OC_VER > 0x0703



	/**
			Constructor to create a complex vector from two vectors - one containing the
			Real parts the other containing the Imaginary parts. The input vectors must have
			a base type of double and must have the same number of elements.
		Example:
			vector vR = { 1, 2, 3 };
			vector vI = { 4, 5, 6 };
			vector <complex> vC(vR, vI);
		Parameters:
			vR=Input vector of doubles
			vI=Input vector of doubles
		Return:
			Returns a complex vector having the same size as vR on successful exit and
			return an empty complex vector object on failure.
	*/
	vector(vector &vR, vector &vI); // Complex vector constructor.


	/**
		Adds One element at the end of the vector. 
	Parameters:
		element = The element to be added to this vector.
	Return:
		The index of the added element.
	Example:
		void test()
		{
			vector<string> vsExt = {"OPJ", "TXT"};
			vsExt.Add("SPC");

			for(int ii = 0; ii < vsExt.GetSize(); ii++)
			{
				printf("Extesion(%d) : %s\n", ii, vsExt[ii]);
			}
		}
	Remarks:
	SeeAlso:
	*/
	int Add(_TemplType element);
	
	/**
		Sets the vector element at the specified index. 
	Parameters:
		nIndex = A specified index in vector.
		element = The element to be added to this vector.
	Return:
		Always returns TRUE
	Example:
		void test()
		{
			vector<string> vsExt = {"OPJ", "TXT"};
			vsExt.SetAtGrow(0, "SPC");

			for(int ii = 0; ii < vsExt.GetSize(); ii++)
			{
				printf("Extesion(%d) : %s\n", ii, vsExt[ii]);
			}
		}
	Remarks:
	SeeAlso:
	*/
	BOOL SetAtGrow(int nIndex, _TemplType element);

	/**
		Inserts one element, or multiple copies of an element at a specified index in an vector.
		In the process, by incrementing the index, it shifts up the existing element at this index, and it shifts up all the elements above it. 
	Parameters:
		nIndex = A specified index in vector.
		element = The element to be added to this vector.
		nCount = The number of times this element should be inserted (defaults to 1).
	Return:
		Always returns TRUE
	Example:
		void test()
		{
			vector<string> vsExt = {"OPJ", "TXT"};
			vsExt.InsertAt(0, "SPC");

			for(int ii = 0; ii < vsExt.GetSize(); ii++)
			{
				printf("Extesion(%d) : %s\n", ii, vsExt[ii]);
			}
		}
	Remarks:
	SeeAlso:
	*/
	BOOL InsertAt(int nIndex, _TemplType element, int nCount = 1);

	/**
		Removes one or more elements starting at a specified index in an vector. 
		In the process, it shifts down all the elements above the removed element(s).
		It decrements the upper bound of the vector.
	Parameters:
		nIndex = A specified index in vector.
		nCount = The number of elements to remove (defaults to 1).
	Return:
		Always returns TRUE
	Example:
		void test()
		{
			vector<string> vsExt = {"OPJ", "TXT", "SPC"};
			vsExt.RemoveAt(0, 2);

			for(int ii = 0; ii < vsExt.GetSize(); ii++)
			{
				printf("Extesion(%d) : %s\n", ii, vsExt[ii]);
			}
		}
	Remarks:
		If nIndex is out of bound, or if (nIndex + nCount-1) is out of bound, then 
		runtime error will be generated.
		
	SeeAlso:
	*/
	BOOL RemoveAt( int nIndex, int nCount = 1 );


	/**
		Find a specified string in an string vector.
	Parameters:
		lpcsz = the specified string
		nStart = start index, defaults to 0.
		bCaseSensitive = 
	Return:
		Return value will be -1 if lpcsz is not found else zero based index of element position
	Example:
		void test()
		{
			vector<string> vsExt = {"OPJ", "TXT"};
			ASSERT( -1 == vsExt.Find("SPC") );
		}
	Remarks:
	SeeAlso:
	*/
	int Find(_TemplType element, int nStart = 0, bool bCaseSensitive = false);
	
	
#if  _OC_VER > 0x0703
	/**#
		gets the range inside the source  data when the constructor
		vector(Column& cc, int nLowerIndex = -1, int nUpperIndex = -1, int nWriteback = WRITEBACK_NO)
		is used. See that constructor and the accompanying example for more details.
	Parameters:
		nLower=receives the value of the lower index in used the source
		nUpper=receives the value of the upper index in used the source
	Return:
		TRUE if nWriteback was not WRITEBACK_NO when calling the constructor. 
	*/
	bool	GetSourceRange(int &nLower, int &nUpper);
#endif //#if  _OC_VER > 0x0703

};

// For testing files that are also compiled in MFC
#define INTVEC vector<int>
#define REALVEC	vector<double>
	

/** >Composite Data Types
		An Origin C Dataset is a dynamically allocated and sized array that is tied
		to an internal Origin data set. The internal Origin data set can either be
		displayed or not displayed in an Origin worksheet column. Dataset is a
		template class with a default type of double but a Dataset of any basic data
		type (including char, byte, short, word, int, and uint but not string) can be
		constructed using the syntax Dataset<type>. OVector can be used as a synonym
		for Dataset. The Dataset class is derived from the vector and vectorbase classes
		from which it inherits methods and properties.
	Example:
		// Worksheet column Data1_B must exist prior to execution
		Dataset dsB;           // Create Origin C Dataset object not attached to an Origin data set 
		dsB.Attach("Data1_B"); // Attach Origin C Dataset object dsB to Origin data set Data1_B
		dsB.SetSize(5);
		dsB = 100;
*/
class Dataset : public vector
{

public:
	
	/**
			Default constructor to create an Origin C Dataset object that is not
			attached to an internal Origin data set. The Origin C Dataset object
			can be attached to an internal Origin data set at a later time.
		Example:
			// Worksheet column Data1_B must exist prior to execution
			Dataset dsB;           // Create Origin C Dataset object not attached to an Origin data set 
			dsB.Attach("Data1_B"); // Attach Origin C Dataset object dsB to Origin data set Data1_B
			dsB.SetSize(5);
			dsB = 1;
		SeeAlso:
			Dataset::Attach, Dataset::Detach
	*/
	Dataset(); // Default constructor for Dataset class.
	
	/**
			Constructor to create an Origin C Dataset object and attach it to an internal
			Origin data set whose name is passed as an argument.
		Example:
			// Worksheet column Data1_B must exist prior to execution
			Dataset dsB("Data1_B"); // Create an Origin C Dataset object attached to an Origin data set
			dsB.SetSize(5);
			dsB = 2;
		Parameters:
			lpcszDatasetName=Name of internal Origin data set to which Origin C object is attached
		SeeAlso:
			Dataset::Attach, Dataset::Detach
	*/
	Dataset(LPCSTR lpcszDatasetName); // Constructor to create a Dataset from data set name.
	
	/**
			Constructor to create an Origin C Dataset object and attach it to an
			Origin worksheet column. Origin worksheet name and column number in worksheet
			are passed as arguments. Please note Origin C column numbers are 0 based
			offsets while internal Origin column numbers are 1 based offsets.
		Example:
			// Worksheet columns Data1_A and Data1_B must exist prior to execution
			Dataset dsB("Data1",1); // Create an Origin C Dataset object attached to an Origin data set
			                        //   contained in column 2 of Origin worksheet Data1
			dsB.SetSize(5);
			dsB = 3;
		Parameters:
			lpcszWksName=Name of worksheet in which column resides
			nCol=Origin C column number to attach to (nCol=1 attaches to second column in worksheet) 
		SeeAlso:
			Dataset::Attach, Dataset::Detach
	*/	
	Dataset(LPCSTR lpcszWksName, int nCol); // Constructor to create a Dataset from worksheet name and column number.

	/**
			Dataset copy constructor accepts an Origin C Dataset object as an argument
			and generates a temporary Dataset which is an exact	copy (same size and 
			values as original) of the Dataset. The temporary Dataset is destroyed 
			when program control exits the scope of the temporary Dataset.
		Example:
			void Test()
			{
				Worksheet wks("Data1");
				Dataset dsA(wks,0);
				
				int nSize = 3;
				dsA.SetSize(nSize);
				for(int ii=0; ii<nSize; ii++)
				{
					dsA[ii] = ii+1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -