SetCompareFunc() private method

private SetCompareFunc ( IntPtr handle, CompareFunc foo ) : int
handle System.IntPtr
foo CompareFunc
return int
コード例 #1
0
ファイル: Database.cs プロジェクト: jpexltd/upscaledb
        /// <summary>
        /// Sets the comparison function
        /// </summary>
        /// <remarks>
        /// This method wraps the native ups_db_set_compare_func function.<br />
        /// <br />
        /// The <see cref="CompareFunc" /> delegate compares two index keys.
        /// It returns -1 if the first key is smaller, +1 if the second key
        /// is smaller or 0 if both keys are equal.<br />
        /// <br />
        /// If <paramref name="foo"/> is null, upscaledb will use the default
        /// compare function (which is based on memcmp(3)).<br />
        /// </remarks>
        /// <param name="foo">The compare delegate, or null</param>
        public void SetCompareFunc(CompareFunc foo)
        {
            int st;

            lock (this) {
                st = NativeMethods.SetCompareFunc(handle, pinnedCompareFunc);
            }
            if (st != 0)
            {
                throw new DatabaseException(st);
            }
            CompareFoo = foo;
        }
コード例 #2
0
        /// <summary>
        /// Sets the comparison function
        /// </summary>
        /// <remarks>
        /// This method wraps the native ups_db_set_compare_func function.<br />
        /// <br />
        /// The <see cref="CompareFunc" /> delegate compares two index keys.
        /// It returns -1 if the first key is smaller, +1 if the second key
        /// is smaller or 0 if both keys are equal.<br />
        /// <br />
        /// If <paramref name="foo"/> is null, upscaledb will use the default
        /// compare function (which is based on memcmp(3)).<br />
        /// </remarks>
        /// <param name="foo">The compare delegate, or null</param>
        public void SetCompareFunc(CompareFunc foo)
        {
            int st;

            lock (this) {
                CompareFunc pinned = new CompareFunc(foo);
                callbacks.Add(pinned);
                st = NativeMethods.SetCompareFunc(handle, pinned);
            }
            if (st != 0)
            {
                throw new DatabaseException(st);
            }
        }