当前位置: 首页>>代码示例>>C#>>正文


C# Slice类代码示例

本文整理汇总了C#中Slice的典型用法代码示例。如果您正苦于以下问题:C# Slice类的具体用法?C# Slice怎么用?C# Slice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Slice类属于命名空间,在下文中一共展示了Slice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestEmptySliceAtMid

        public void TestEmptySliceAtMid()
        {
            Slice<int> x = new Slice<int>(new[] { 1, 2, 3, 4 });
            x = x.Slc(1, 1);

            Assert.IsEmpty(x.ToArray());
        }
开发者ID:yonglehou,项目名称:NsqSharp,代码行数:7,代码来源:SliceTest.cs

示例2: Contains

		public bool Contains(string treeName, Slice key, out ushort? version, WriteBatch writeBatch = null)
		{
			if (writeBatch != null)
			{
				WriteBatch.BatchOperationType operationType;
				Stream stream;
				if (writeBatch.TryGetValue(treeName, key, out stream, out version, out operationType))
				{
					switch (operationType)
					{
						case WriteBatch.BatchOperationType.Add:
							return true;
						case WriteBatch.BatchOperationType.Delete:
							return false;
						default:
							throw new ArgumentOutOfRangeException(operationType.ToString());
					}
				}
			}

			var tree = GetTree(treeName);
			var readVersion = tree.ReadVersion(key);

			var exists = readVersion > 0;

			version = exists ? (ushort?)readVersion : null;

			return exists;
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:29,代码来源:SnapshotReader.cs

示例3: TestCreateOverArray

    public bool TestCreateOverArray(Tester t)
    {
        for (int i = 0; i < 2; i++) {
            var ints = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

            // Try out two ways of creating a slice:
            Slice<int> slice;
            if (i == 0) {
                slice = new Slice<int>(ints);
            }
            else {
                slice = ints.Slice();
            }
            t.AssertEqual(ints.Length, slice.Length);

            // Now try out two ways of walking the slice's contents:
            for (int j = 0; j < ints.Length; j++) {
                t.AssertEqual(ints[j], slice[j]);
            }
            {
                int j = 0;
                foreach (var x in slice) {
                    t.AssertEqual(ints[j], x);
                    j++;
                }
            }
        }
        return true;
    }
开发者ID:JeanSebTr,项目名称:slice.net,代码行数:29,代码来源:Tests.cs

示例4: FindShortestSeparator

        public override void FindShortestSeparator(ref string start, Slice limit)
        {
            // Find length of common prefix
            int minLength = Math.Min(start.Length, limit.Size);
            int diffIndex = 0;

            while ((diffIndex < minLength) && (start[diffIndex].Equals((char)limit[diffIndex])))
            {
                diffIndex++;
            }

            if (diffIndex >= minLength)
            {
                // Do not shorten if one string is a prefix of the other
            }
            else
            {
                byte diffByte = (byte)start[diffIndex];
                if (diffByte < 0xff &&
                    diffByte + 1 < limit[diffIndex])
                {
                    start = start.Set(diffIndex,(char) (start[diffIndex] + 1));

                    start = start.Resize(diffIndex + 1);

                    Debug.Assert(Compare(new Slice(start), limit) < 0);
                }
            }
        }
开发者ID:somdoron,项目名称:NetLevelDB,代码行数:29,代码来源:BytewiseComparator.cs

示例5: FdbWatch

		internal FdbWatch(FdbFuture<Slice> future, Slice key, Slice value)
		{
			Contract.Requires(future != null);
			m_future = future;
			m_key = key;
			m_value = value;
		}
开发者ID:rektide,项目名称:foundationdb-dotnet-client,代码行数:7,代码来源:FdbWatch.cs

示例6: Status

        private Status(CodeEnum code, Slice msg, Slice msg2)
        {
            Debug.Assert(code != CodeEnum.kOk);
            int len1 = msg.Size;

            int len2 = 0;

            if (msg2 != null)
            {
                len2 = msg2.Size;
            }

            int size = len1 + (len2 != 0 ? (2 + len2) : 0);
            byte[] result = new byte[size + 5];

            Buffer.BlockCopy(BitConverter.GetBytes(size), 0, result, 0, 4);

            result[4] = (byte) Code;

            msg.Data.CopyTo(result,5, len1);

            if (len2!=0)
            {
                result[5 + len1] = (byte)':';
                result[6 + len1] = (byte)' ';

                msg2.Data.CopyTo(result, 7 + len1, len2);
            }

            m_state = result;
        }
开发者ID:somdoron,项目名称:NetLevelDB,代码行数:31,代码来源:Status.cs

示例7: OnData

        /// <summary>
        /// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
        /// </summary>
        /// <param name="data">Slice object keyed by symbol containing the stock data</param>
        public override void OnData(Slice data)
        {
            // MARKET ORDERS

            MarketOrders();

            // LIMIT ORDERS

            LimitOrders();

            // STOP MARKET ORDERS

            StopMarketOrders();

            // STOP LIMIT ORDERS

            StopLimitOrders();

            // MARKET ON OPEN ORDERS

            MarketOnOpenOrders();

            // MARKET ON CLOSE ORDERS

            MarketOnCloseOrders();
        }
开发者ID:skyfyl,项目名称:Lean,代码行数:30,代码来源:OrderTicketDemoAlgorithm.cs

示例8: CreateOrOpenAsync

		/// <summary>Opens the directory with the given <paramref name="path"/>.
		/// If the directory does not exist, it is created (creating parent directories if necessary).
		/// If layer is specified, it is checked against the layer of an existing directory or set as the layer of a new directory.
		/// </summary>
		public static Task<FdbDirectorySubspace> CreateOrOpenAsync(this IFdbDirectory directory, IFdbTransactional db, IEnumerable<string> path, Slice layer, CancellationToken cancellationToken)
		{
			if (directory == null) throw new ArgumentNullException("directory");
			if (db == null) throw new ArgumentNullException("db");
			if (path == null) throw new ArgumentNullException("path");
			return db.ReadWriteAsync((tr) => directory.CreateOrOpenAsync(tr, path, layer), cancellationToken);
		}
开发者ID:Rustemt,项目名称:foundationdb-dotnet-client,代码行数:11,代码来源:FdbDirectoryTransactionals.cs

示例9: Seek

		public bool Seek(Slice key)
		{
			if (this.ValidateCurrentKey(Current, _cmp) == false)
				return false;
			CurrentKey = NodeHeader.GetData(_tx, _item);
			return true;
		}
开发者ID:randacc,项目名称:ravendb,代码行数:7,代码来源:SingleEntryIterator.cs

示例10: DecodeFrom

        public Status DecodeFrom(ref Slice input)
        {
            ByteArrayPointer magicPtr = input.Data + (kEncodedLength - 8);

            UInt32 magicLo = Coding.DecodeFixed32(magicPtr);
            UInt32 magicHi = Coding.DecodeFixed32(magicPtr + 4);

            UInt64 magic = (((UInt64)(magicHi) << 32) | ((UInt64)(magicLo)));

            if (magic != FormatHelper.kTableMagicNumber)
            {
                return Status.InvalidArgument("not an sstable (bad magic number)");
            }

            Status result = MetaindexHandle.DecodeFrom(ref input);
            if (result.IsOk)
            {
                result = IndexHandle.DecodeFrom(ref input);
            }
            if (result.IsOk)
            {
                // We skip over any leftover data (just padding for now) in "input"
                ByteArrayPointer end = magicPtr + 8;
                input = new Slice(end, input.Data + input.Size - end);
            }

            return result;
        }
开发者ID:somdoron,项目名称:NetLevelDB,代码行数:28,代码来源:Footer.cs

示例11: ActivityEntry

 public ActivityEntry(DebugActionType actionType, Slice key, string treeName, object value)
 {
     ActionType = actionType;
     Key = key;
     TreeName = treeName;
     Value = value;
 }
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:7,代码来源:DebugJournal.cs

示例12: Store

		private unsafe USlice Store(Slice data)
		{
			uint size = checked((uint)data.Count);
			var buffer = m_keys.AllocateAligned(size);
			UnmanagedHelpers.CopyUnsafe(buffer, data);
			return new USlice(buffer, size);
		}
开发者ID:rektide,项目名称:foundationdb-dotnet-client,代码行数:7,代码来源:TransactionWindow.cs

示例13: TestEmptySliceAtZero

        public void TestEmptySliceAtZero()
        {
            Slice<char> x = new Slice<char>("test!");
            x = x.Slc(0, 0);

            Assert.AreEqual("", x.ToString());
        }
开发者ID:yonglehou,项目名称:NsqSharp,代码行数:7,代码来源:SliceTest.cs

示例14: Indexing_ThrowsIfOutOfRange

        public void Indexing_ThrowsIfOutOfRange()
        {
            var inner = new[] { 1, 2, 3, 4, 5 };
            var subject = new Slice<int>(inner, 1, 2);

            Check.ThatCode(() => subject[3]).Throws<IndexOutOfRangeException>();
        }
开发者ID:akatakritos,项目名称:PygmentSharp,代码行数:7,代码来源:SliceTests.cs

示例15: Match

        public bool Match(Slice slice)
        {
            MemoryAccess acc = slice.Expression as MemoryAccess;
            if (acc == null)
                return false;

            b = acc.EffectiveAddress;
            Constant offset = Constant.Create(b.DataType, 0);
            BinaryOperator op = Operator.IAdd;
            BinaryExpression ea = b as BinaryExpression;
            if (ea != null)
            {
                Constant c= ea.Right as Constant;
                if (c != null)
                {
                    offset = c;
                    b = ea.Left;
                }
            }
            else
            {
                b = acc.EffectiveAddress;
            }
            int bitBegin = slice.Offset;
            int bitEnd = bitBegin + slice.DataType.BitSize;
            if (0 <= bitBegin && bitEnd <= acc.DataType.BitSize)
            {
                offset = op.ApplyConstants(offset, Constant.Create(acc.EffectiveAddress.DataType, slice.Offset / 8));
                b = new MemoryAccess(acc.MemoryId, new BinaryExpression(op, offset.DataType, b, offset), slice.DataType);
                return true;
            }
            return false;
        }
开发者ID:nemerle,项目名称:reko,代码行数:33,代码来源:SliceMem_Rule.cs


注:本文中的Slice类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。