當前位置: 首頁>>代碼示例>>C#>>正文


C# CollSeq.xCmp方法代碼示例

本文整理匯總了C#中CollSeq.xCmp方法的典型用法代碼示例。如果您正苦於以下問題:C# CollSeq.xCmp方法的具體用法?C# CollSeq.xCmp怎麽用?C# CollSeq.xCmp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CollSeq的用法示例。


在下文中一共展示了CollSeq.xCmp方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: sqlite3MemCompare


//.........這裏部分代碼省略.........
						r1 = pMem1.r;
					}
					if ((f2 & MEM_Real) == 0)
					{
						r2 = (double)pMem2.u.i;
					}
					else
					{
						r2 = pMem2.r;
					}
					if (r1 < r2)
						return -1;
					if (r1 > r2)
						return 1;
					return 0;
				}
				else
				{
					Debug.Assert((f1 & MEM_Int) != 0);
					Debug.Assert((f2 & MEM_Int) != 0);
					if (pMem1.u.i < pMem2.u.i)
						return -1;
					if (pMem1.u.i > pMem2.u.i)
						return 1;
					return 0;
				}
			}

			/* If one value is a string and the other is a blob, the string is less.
			** If both are strings, compare using the collating functions.
			*/
			if ((combined_flags & MEM_Str) != 0)
			{
				if ((f1 & MEM_Str) == 0)
				{
					return 1;
				}
				if ((f2 & MEM_Str) == 0)
				{
					return -1;
				}

				Debug.Assert(pMem1.enc == pMem2.enc);
				Debug.Assert(pMem1.enc == SQLITE_UTF8 ||
				pMem1.enc == SQLITE_UTF16LE || pMem1.enc == SQLITE_UTF16BE);

				/* The collation sequence must be defined at this point, even if
				** the user deletes the collation sequence after the vdbe program is
				** compiled (this was not always the case).
				*/
				Debug.Assert(pColl == null || pColl.xCmp != null);

				if (pColl != null)
				{
					if (pMem1.enc == pColl.enc)
					{
						/* The strings are already in the correct encoding.  Call the
						** comparison function directly */
						return pColl.xCmp(pColl.pUser, pMem1.n, pMem1.z, pMem2.n, pMem2.z);
					}
					else
					{
						string v1, v2;
						int n1, n2;
						Mem c1 = null;
						Mem c2 = null;

						c1 = sqlite3Malloc(c1);// memset( &c1, 0, sizeof( c1 ) );
						c2 = sqlite3Malloc(c2);// memset( &c2, 0, sizeof( c2 ) );

						sqlite3VdbeMemShallowCopy(c1, pMem1, MEM_Ephem);
						sqlite3VdbeMemShallowCopy(c2, pMem2, MEM_Ephem);
						v1 = sqlite3ValueText((sqlite3_value)c1, pColl.enc);
						n1 = v1 == null ? 0 : c1.n;
						v2 = sqlite3ValueText((sqlite3_value)c2, pColl.enc);
						n2 = v2 == null ? 0 : c2.n;
						rc = pColl.xCmp(pColl.pUser, n1, v1, n2, v2);
						sqlite3VdbeMemRelease(c1);
						sqlite3VdbeMemRelease(c2);
						return rc;
					}
				}
				/* If a NULL pointer was passed as the collate function, fall through
				** to the blob case and use memcmp().  */
			}

			/* Both values must be blobs.  Compare using memcmp().  */
			if ((pMem1.flags & MEM_Blob) != 0)
				if (pMem1.zBLOB != null)
					rc = memcmp(pMem1.zBLOB, pMem2.zBLOB, (pMem1.n > pMem2.n) ? pMem2.n : pMem1.n);
				else
					rc = memcmp(pMem1.z, pMem2.zBLOB, (pMem1.n > pMem2.n) ? pMem2.n : pMem1.n);
			else
				rc = memcmp(pMem1.z, pMem2.z, (pMem1.n > pMem2.n) ? pMem2.n : pMem1.n);
			if (rc == 0)
			{
				rc = pMem1.n - pMem2.n;
			}
			return rc;
		}
開發者ID:broettge,項目名稱:MatterControl,代碼行數:101,代碼來源:vdbemem_c.cs


注:本文中的CollSeq.xCmp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。