Example #1
0
 public int Search(IComparable data)
 {
     if (arr[data.GetHashCode() % arr.Length] != null)
     {
         return(data.GetHashCode());
     }
     return(-1);
 }
Example #2
0
        public void Insert(IComparable data)
        {
            int hashCode = Math.Abs(data.GetHashCode());
            int index    = hashCode % iCompArr.Length;

            iCompArr[index] = data;
        }
Example #3
0
        public void Insert(IComparable data)
        {
            int hashCode = data.GetHashCode();
            int index    = hashCode % clubMemberArray.Length;

            clubMemberArray[index] = data;
        }
 public override int GetHashCode()
 {
     unchecked
     {
         return((_bounds.GetHashCode() * 397) ^ Token.GetHashCode());
     }
 }
Example #5
0
        public void Insert(IComparable data)
        {
            int placeholder = data.GetHashCode() % cmArray.Length;

            if (placeholder < 0)
            {
                placeholder = placeholder * -1;
            }
            cmArray[placeholder] = data;
        }
Example #6
0
        public int Search(IComparable data)
        {
            int result   = -1;
            int hashCode = Math.Abs(data.GetHashCode());
            int index    = hashCode % iCompArr.Length;

            if (iCompArr[index].Equals(data))
            {
                result = index;
            }

            return(result);
        }
Example #7
0
        public int GetIndex(IComparable element)
        {
            int placeholder = element.GetHashCode() % cmArray.Length;

            if (placeholder < 0)
            {
                return(placeholder * -1);
            }
            else
            {
                return(placeholder);
            }
        }
Example #8
0
 public void CheckEqualCompHash(IComparable o1, IComparable o2)
 {
     if (o1.Equals(o2))
     {
         Assert.IsTrue(o2.Equals(o1), "Equals reflexivity (true)");
         Assert.IsTrue(o1.CompareTo(o2) == 0, "Equals consistency 1 (true)");
         Assert.IsTrue(o2.CompareTo(o1) == 0, "Equals (ref) consistency 1 (true)");
         Assert.IsTrue(o1.GetHashCode() == o2.GetHashCode(), "Equals Hash consistency 1");
     }
     else
     {
         Assert.IsFalse(o2.Equals(o1), "Equals reflexivity (false)");
         Assert.IsFalse(o1.CompareTo(o2) == 0, "Equals consistency 1 (false)");
         Assert.IsTrue(o2.CompareTo(o1) != 0, "Equals (ref) consistency 1 (false)");
     }
 }
Example #9
0
        public int Search(IComparable data)
        {
            int placeholder = data.GetHashCode() % cmArray.Length;

            if (placeholder < 0)
            {
                return(placeholder * -1);
            }
            if (cmArray[placeholder] == null)
            {
                return(-1);
            }
            else
            {
                return(placeholder);
            }
        }
Example #10
0
 public override int GetHashCode()
 {
     return(_comparable.GetHashCode());
 }
Example #11
0
 public override int GetHashCode()
 {
     return(_key == null ? 0 : _key.GetHashCode());
 }
Example #12
0
 /// <summary>
 /// Returns a hash code.
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     return(mKey.GetHashCode());
 }
        public void DeleteWorkflowQueue(IComparable queueName)
        {
            if (queueName == null)
                throw new ArgumentNullException("queueName");

            lock (SyncRoot)
            {
                // when we are deleting the queue from activity
                // message delivery should not happen.
                if (this.rootQueuingService != null && !IsTransactionalQueue(queueName))
                {
                    this.rootQueuingService.DeleteWorkflowQueue(queueName);
                    return;
                }

                EventQueueState queueState = GetEventQueueState(queueName);

                Queue queue = queueState.Messages;
                Queue pendingQueue = this.pendingQueueState.Messages;

                while (queue.Count != 0)
                {
                    pendingQueue.Enqueue(queue.Dequeue());
                }

                WorkflowTrace.Runtime.TraceInformation("Queuing Service: Deleting Queue with ID {0} for {1}", queueName.GetHashCode(), queueName);
                this.persistedQueueStates.Remove(queueName);
            }
        }
        public void DeleteWorkflowQueue(IComparable queueName)
        {
            if (queueName == null)
            {
                throw new ArgumentNullException("queueName");
            }

            lock (SyncRoot)
            {
                // when we are deleting the queue from activity
                // message delivery should not happen.
                if (this.rootQueuingService != null && !IsTransactionalQueue(queueName))
                {
                    this.rootQueuingService.DeleteWorkflowQueue(queueName);
                    return;
                }

                EventQueueState queueState = GetEventQueueState(queueName);

                Queue queue        = queueState.Messages;
                Queue pendingQueue = this.pendingQueueState.Messages;

                while (queue.Count != 0)
                {
                    pendingQueue.Enqueue(queue.Dequeue());
                }

                WorkflowTrace.Runtime.TraceInformation("Queuing Service: Deleting Queue with ID {0} for {1}", queueName.GetHashCode(), queueName);
                this.persistedQueueStates.Remove(queueName);
            }
        }
Example #15
0
 /// <summary>
 /// Gets the hashcode
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     return(obj.GetHashCode());
 }
Example #16
0
 public override int GetHashCode()
 {
     return(_value.GetHashCode());
 }
Example #17
0
 public void Insert(IComparable data)
 {
     arr[data.GetHashCode() % arr.Length] = data;
 }
Example #18
0
 internal bool SafeEnqueueEvent(IComparable queueName, object item)
 {
     if (queueName == null)
     {
         throw new ArgumentNullException("queueName");
     }
     lock (this.SyncRoot)
     {
         if ((this.rootQueuingService != null) && !this.IsTransactionalQueue(queueName))
         {
             return(this.rootQueuingService.SafeEnqueueEvent(queueName, item));
         }
         EventQueueState queue = this.GetQueue(queueName);
         if (!queue.Enabled)
         {
             throw new QueueException(string.Format(CultureInfo.CurrentCulture, ExecutionStringManager.QueueNotEnabled, new object[] { queueName }), MessageQueueErrorCode.QueueNotAvailable);
         }
         queue.Messages.Enqueue(item);
         WorkflowTrace.Runtime.TraceInformation("Queuing Service: Enqueue item Queue ID {0} for {1}", new object[] { queueName.GetHashCode(), queueName });
         for (int i = 0; (this.messageArrivalEventHandlers != null) && (i < this.messageArrivalEventHandlers.Count); i++)
         {
             this.messageArrivalEventHandlers[i].OnItemSafeEnqueued(queueName, item);
         }
         this.NotifySynchronousSubscribers(queueName, queue, item);
         return(this.QueueAsynchronousEvent(queueName, queue));
     }
 }
        internal bool SafeEnqueueEvent(IComparable queueName, Object item)
        {
            if (queueName == null)
            {
                throw new ArgumentNullException("queueName");
            }

            lock (SyncRoot)
            {
                if (this.rootQueuingService != null && !IsTransactionalQueue(queueName))
                {
                    return(this.rootQueuingService.SafeEnqueueEvent(queueName, item));
                }

                EventQueueState qState = GetQueue(queueName);
                if (!qState.Enabled)
                {
                    throw new QueueException(String.Format(CultureInfo.CurrentCulture, ExecutionStringManager.QueueNotEnabled, queueName), MessageQueueErrorCode.QueueNotAvailable);
                }

                // note enqueue allowed irrespective of dirty flag since it is delivered through
                qState.Messages.Enqueue(item);

                WorkflowTrace.Runtime.TraceInformation("Queuing Service: Enqueue item Queue ID {0} for {1}", queueName.GetHashCode(), queueName);

                // notify message arrived subscribers
                for (int i = 0; messageArrivalEventHandlers != null && i < messageArrivalEventHandlers.Count; ++i)
                {
                    this.messageArrivalEventHandlers[i].OnItemSafeEnqueued(queueName, item);
                }

                NotifySynchronousSubscribers(queueName, qState, item);
                return(QueueAsynchronousEvent(queueName, qState));
            }
        }
 internal bool SafeEnqueueEvent(IComparable queueName, object item)
 {
     if (queueName == null)
     {
         throw new ArgumentNullException("queueName");
     }
     lock (this.SyncRoot)
     {
         if ((this.rootQueuingService != null) && !this.IsTransactionalQueue(queueName))
         {
             return this.rootQueuingService.SafeEnqueueEvent(queueName, item);
         }
         EventQueueState queue = this.GetQueue(queueName);
         if (!queue.Enabled)
         {
             throw new QueueException(string.Format(CultureInfo.CurrentCulture, ExecutionStringManager.QueueNotEnabled, new object[] { queueName }), MessageQueueErrorCode.QueueNotAvailable);
         }
         queue.Messages.Enqueue(item);
         WorkflowTrace.Runtime.TraceInformation("Queuing Service: Enqueue item Queue ID {0} for {1}", new object[] { queueName.GetHashCode(), queueName });
         for (int i = 0; (this.messageArrivalEventHandlers != null) && (i < this.messageArrivalEventHandlers.Count); i++)
         {
             this.messageArrivalEventHandlers[i].OnItemSafeEnqueued(queueName, item);
         }
         this.NotifySynchronousSubscribers(queueName, queue, item);
         return this.QueueAsynchronousEvent(queueName, queue);
     }
 }
 public void DeleteWorkflowQueue(IComparable queueName)
 {
     if (queueName == null)
     {
         throw new ArgumentNullException("queueName");
     }
     lock (this.SyncRoot)
     {
         if ((this.rootQueuingService != null) && !this.IsTransactionalQueue(queueName))
         {
             this.rootQueuingService.DeleteWorkflowQueue(queueName);
         }
         else
         {
             Queue messages = this.GetEventQueueState(queueName).Messages;
             Queue queue2 = this.pendingQueueState.Messages;
             while (messages.Count != 0)
             {
                 queue2.Enqueue(messages.Dequeue());
             }
             WorkflowTrace.Runtime.TraceInformation("Queuing Service: Deleting Queue with ID {0} for {1}", new object[] { queueName.GetHashCode(), queueName });
             this.persistedQueueStates.Remove(queueName);
         }
     }
 }
Example #22
0
 public override int GetHashCode()
 {
     return(Object.GetHashCode());
 }
        internal bool SafeEnqueueEvent(IComparable queueName, Object item)
        {
            if (queueName == null)
                throw new ArgumentNullException("queueName");

            lock (SyncRoot)
            {
                if (this.rootQueuingService != null && !IsTransactionalQueue(queueName))
                {
                    return this.rootQueuingService.SafeEnqueueEvent(queueName, item);
                }

                EventQueueState qState = GetQueue(queueName);
                if (!qState.Enabled)
                {
                    throw new QueueException(String.Format(CultureInfo.CurrentCulture, ExecutionStringManager.QueueNotEnabled, queueName), MessageQueueErrorCode.QueueNotAvailable);
                }

                // note enqueue allowed irrespective of dirty flag since it is delivered through
                qState.Messages.Enqueue(item);

                WorkflowTrace.Runtime.TraceInformation("Queuing Service: Enqueue item Queue ID {0} for {1}", queueName.GetHashCode(), queueName);

                // notify message arrived subscribers
                for (int i = 0; messageArrivalEventHandlers != null && i < messageArrivalEventHandlers.Count; ++i)
                {
                    this.messageArrivalEventHandlers[i].OnItemSafeEnqueued(queueName, item);
                }

                NotifySynchronousSubscribers(queueName, qState, item);
                return QueueAsynchronousEvent(queueName, qState);
            }
        }
 public override int GetHashCode()
 {
     return(value != null ? value.GetHashCode() : 0);
 }
        private void NewQueue(IComparable queueID, bool enabled, bool transactional)
        {
            WorkflowTrace.Runtime.TraceInformation("Queuing Service: Creating new Queue with ID {0} for {1}", queueID.GetHashCode(), queueID);

            if (this.persistedQueueStates.ContainsKey(queueID))
            {
                object[] args =
                    new object[] { System.Messaging.MessageQueueErrorCode.QueueExists, queueID };
                string message =
                    string.Format(CultureInfo.CurrentCulture, ExecutionStringManager.EventQueueException, args);

                throw new QueueException(message, MessageQueueErrorCode.QueueExists);
            }

            EventQueueState queueState = new EventQueueState();
            queueState.Enabled = enabled;
            queueState.queueName = queueID;
            queueState.Transactional = transactional;
            this.persistedQueueStates.Add(queueID, queueState);
        }
Example #26
0
 public void DeleteWorkflowQueue(IComparable queueName)
 {
     if (queueName == null)
     {
         throw new ArgumentNullException("queueName");
     }
     lock (this.SyncRoot)
     {
         if ((this.rootQueuingService != null) && !this.IsTransactionalQueue(queueName))
         {
             this.rootQueuingService.DeleteWorkflowQueue(queueName);
         }
         else
         {
             Queue messages = this.GetEventQueueState(queueName).Messages;
             Queue queue2   = this.pendingQueueState.Messages;
             while (messages.Count != 0)
             {
                 queue2.Enqueue(messages.Dequeue());
             }
             WorkflowTrace.Runtime.TraceInformation("Queuing Service: Deleting Queue with ID {0} for {1}", new object[] { queueName.GetHashCode(), queueName });
             this.persistedQueueStates.Remove(queueName);
         }
     }
 }
        private void NewQueue(IComparable queueID, bool enabled, bool transactional)
        {
            WorkflowTrace.Runtime.TraceInformation("Queuing Service: Creating new Queue with ID {0} for {1}", queueID.GetHashCode(), queueID);

            if (this.persistedQueueStates.ContainsKey(queueID))
            {
                object[] args =
                    new object[] { System.Messaging.MessageQueueErrorCode.QueueExists, queueID };
                string message =
                    string.Format(CultureInfo.CurrentCulture, ExecutionStringManager.EventQueueException, args);

                throw new QueueException(message, MessageQueueErrorCode.QueueExists);
            }

            EventQueueState queueState = new EventQueueState();

            queueState.Enabled       = enabled;
            queueState.queueName     = queueID;
            queueState.Transactional = transactional;
            this.persistedQueueStates.Add(queueID, queueState);
        }