public override void InsertKeyAndValue(System.IComparable key, object value)
		{
			int position = GetPositionOfKey(key);
			bool addToExistingCollection = false;
			int realPosition = 0;
			if (position >= 0)
			{
				addToExistingCollection = true;
				realPosition = position - 1;
			}
			else
			{
				realPosition = -position - 1;
			}
			// If there is an element at this position and the key is different,
			// then right shift, size
			// safety is guaranteed by the rightShiftFrom method
			if (realPosition < nbKeys && key.CompareTo(keys[realPosition]) != 0)
			{
				RightShiftFrom(realPosition, true);
			}
			keys[realPosition] = key;
			// This is a non unique btree node, manage collection
			ManageCollectionValue(realPosition, value);
			if (!addToExistingCollection)
			{
				nbKeys++;
			}
		}
Exemplo n.º 2
0
 int IPush.SetLocalTimer(int id, bool isTimeoutAvailable, System.TimeSpan period, System.DateTimeOffset time, string title, string text)
 {
     long javaTime = Util.DataTimeToJavaTime(time.UtcDateTime);
     long javaPeriod = (long)period.TotalMilliseconds;
     if(time.CompareTo(System.DateTimeOffset.UtcNow) < 0)
     {
         if(javaPeriod > 1000)
         {
             do
             {
                 time += period;
             }
             while(time.CompareTo(System.DateTimeOffset.UtcNow) <= 0);
             javaTime = Util.DataTimeToJavaTime(time.UtcDateTime);
         }
         else if(isTimeoutAvailable)
         {
             time = System.DateTimeOffset.UtcNow + new System.TimeSpan(0, 0, 10);
             javaTime = Util.DataTimeToJavaTime(time.UtcDateTime);
         }
         else
         {
             return 0;
         }
     }
     return CCPush.SetLocalTimer(id, isTimeoutAvailable, javaPeriod, javaTime, title, text);
 }
Exemplo n.º 3
0
 public static string CompabilityText(Type type, string PluginToInstall, string PluginCompatible, string UniquePlugin, System.Version currVersion, System.Version minVersion)
 {
     string result = string.Format(PluginToInstall, minVersion.ToString(), UniquePlugin);
     try
     {
         if (type != null)
         {
             if (currVersion.CompareTo(minVersion) >= 0)
             {
                 result = string.Format(OtherPluginVersion, currVersion.ToString(), UniquePlugin) + " " +
                     PluginCompatible;
             }
             else
             {
                 result = string.Format(OtherPluginVersion, currVersion.ToString(), UniquePlugin) + " " +
                     string.Format(PluginToInstall, minVersion.ToString(), UniquePlugin);
             }
         }
     }
     catch (Exception)
     {
     }
     return result;
 }
Exemplo n.º 4
0
        private bool CheckTime(System.TimeSpan time)
        {
            if (StartTime.CompareTo(EndTime) < 0)
            {
                return (time.CompareTo(StartTime) >= 0 &&
                    time.CompareTo(EndTime) <= 0);
            }
            else if (StartTime.CompareTo(EndTime) > 0)
            {
                return (time.CompareTo(StartTime) >= 0 ||
                    time.CompareTo(EndTime) <= 0);
            }

            return true;
        }
Exemplo n.º 5
0
            /// <summary>
            /// Creates a new random acces stream with read-write or read rights
            /// </summary>
            /// <param gridTemplateName="fileName">A relative or absolute path for the file to open</param>
            /// <param gridTemplateName="mode">Mode to open the file in</param>
            /// <returns>The new System.IO.FileStream</returns>
            public static System.IO.FileStream CreateRandomAccessFile(System.String fileName, System.String mode)
            {
                System.IO.FileStream newFile = null;

                if (mode.CompareTo("rw") == 0)
                newFile =  new System.IO.FileStream(fileName, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite);
                else if (mode.CompareTo("r") == 0 )
                newFile =  new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                else
                throw new System.ArgumentException();

                return newFile;
            }
		/// <summary>A geenric compare method</summary>
		/// <param name="c1"></param>
		/// <param name="c2"></param>
		/// <returns></returns>
		public static int Compare(System.IComparable c1, System.IComparable c2)
		{
			return c1.CompareTo(c2);
		}
Exemplo n.º 7
0
		private int CompareTo(System.DateTime o1, System.DateTime o2)
		{
			return o1.CompareTo(o2);
		}