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

📄 prioritypacket.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace NCindy.Packet
{
    using NCindy;
    using System;
    using System.Threading;

    public class PriorityPacket : DelegatePacket, IComparable<PriorityPacket>
    {
        private readonly long createSequence;
        private readonly int priority;
        private static long SEQUENCE;

        public PriorityPacket(IPacket packet, int priority) : base(packet)
        {
            this.priority = priority;
            this.createSequence = Interlocked.Increment(ref SEQUENCE);
        }

        public int CompareTo(PriorityPacket other)
        {
            int priority = other.priority;
            if (this.priority < priority)
            {
                return -1;
            }
            if (this.priority > priority)
            {
                return 1;
            }
            return (int) (this.createSequence - other.createSequence);
        }

        public int CompareTo(object obj)
        {
            PriorityPacket packet = (PriorityPacket) obj;
            int priority = packet.priority;
            if (this.priority < priority)
            {
                return -1;
            }
            if (this.priority <= priority)
            {
                return (int) (this.createSequence - packet.createSequence);
            }
            return 1;
        }

        public override string ToString()
        {
            return (base.ToString() + " [priority] " + this.priority);
        }
    }
}

⌨️ 快捷键说明

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