// Returns the next element in the iteration without advancing the iterator. public Integer peek() { if (nextValue == null) { nextValue = this.next(); } return nextValue; }
static void Main() { Integer Num = new Integer(3); Console.WriteLine("덧셈 : " + Num.Add(2)); Console.WriteLine("곱셈 : " + Num.Mul(2)); Console.WriteLine("뺄셈 : " + Num.Sub(2)); }
public static Boolean test(Integer n1, Long n2) { if (n1 < n2) { return true; } else { return false; } }
private async Task ExclusiveTask(SemaphoreSlim s, Integer count, int seed, int iteration, bool due) { var r = new Random(seed); if (due) { try { await Delay(r).ConfigureAwait(false); } catch { } } for (int i = 0; i < iteration; i++) { int localCount = 0; try { await s.WaitAsync(); localCount = count.Value; await Delay(r).ConfigureAwait(false); } catch (TestException) { } finally { count.Value = localCount + 1; s.Release(); } } }
public static bool test() { Integer x = 1; Integer y = new Integer(1); if (x == y) return true; else return false; }
public NetflixMovie(Integer id, String title) { if (id == null || title == null) { throw new ArgumentNullException("ID or title is null"); } this.id = id; this.title = title; }
static void Main(string[] args) { Integer integer = new Integer(21); Method(integer); Console.WriteLine("From Integer instance in Method: " + integer.Integer1); Console.ReadLine(); }
public Integer next() { if (nextValue != null) { int temp = nextValue; nextValue = null; return temp; } else return itr.next(); }
public void IntegerEnsureMaxIsNotExceeded() { // Arrange Integer my_int = new Integer(); // Act int[] actual = my_int.GetSequence(my_int.Max+1); // This is a call the uses an older testing framework. (e.g. Koans) //Assert.Throws(typeof(Exception), my_int.GetSequence(my_int.Max)); }
public void IntegerEnsureICanCreateASequenceOfTenIntegers() { // Arrange Integer my_int = new Integer(); // Act int[] actual = my_int.GetSequence(10); int[] expected = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; // Assert CollectionAssert.AreEqual(expected, actual); }
public void IntegerEnsureICanGetFirstNumber() { // Arrange - Scenario Setup Integer my_int = new Integer(); // Act - Do the thing you want to test int actual = my_int.GetFirst(); int expected = 0; // Assert - Did it work as expected? Assert.AreEqual(expected, actual); }
public void IntegerEnsureICanGetNextInteger() { // Arrange Integer my_int = new Integer(); // Act int actual = my_int.GetNext(5); int expected = 6; // Assert Assert.AreEqual(expected, actual); }
public static bool test() { var list = Query.range(0, 5).toList(); var array1 = new Integer[5]; var array2 = list.toArray(array1); if (array1 != array2) { return false; } for (int i = 0; i < sizeof(array1); i++) { if (!array1[i].equals(i)) { return false; } } return true; }
public RSAPrivateKey(Integer version, Integer modulus, Integer publicExponent, Integer privateExponent, Integer prime1, Integer prime2, Integer exponent1, Integer exponent2, Integer coefficient) : base(version, modulus, publicExponent, privateExponent, prime1, prime2, exponent1, exponent2, coefficient) { Key = new RSAParameters() { Modulus = AddPadding(modulus.UnencodedValue), Exponent = publicExponent.UnencodedValue, // the exponent does not require padding D = AddPadding(privateExponent.UnencodedValue), P = AddPadding(prime1.UnencodedValue), Q = AddPadding(prime2.UnencodedValue), DP = AddPadding(exponent1.UnencodedValue), DQ = AddPadding(exponent2.UnencodedValue), InverseQ = AddPadding(coefficient.UnencodedValue) }; }
private async Task TestWaitAsyncInternal(int parallel, int innerLoop, int outerLoop, bool due) { var r = new Random(); var s = new SemaphoreSlim(1); for (int i = 0; i < outerLoop; i++) { var count = new Integer(); await Task.WhenAll(Enumerable.Range(0, parallel) .Select(_ => ExclusiveTask(s, count, r.Next(), innerLoop, due)) .ToArray()); Assert.AreEqual(parallel * innerLoop, count.Value); } }
public override void Main() { foreach(var ship in MyShip.SRS) { Response.Add(ship.GetNameHtmlAndID()); Response.Add(new CHtmlBreak()); } Array<Integer> a = new Integer[]{ 4, 9 }; Integer n = a[1]; Array<Integer> b = new Integer[5,n*2]; Integer n2 = b[4, 0]; WriteLine(n + " " + n2); foreach(var i in a) { WriteLine(i + " is in a"); } }
static public void Main(string[] args) { BinaryFormatter formatter = new BinaryFormatter(); Console.WriteLine("record size\trecords written\tbytes per record\trecords per sec\tintegers per sec"); for (int n=1; n<50000; n=(int)(1.2*n)+1) { using (FileStream fos = new FileStream("tmp.tmp", FileMode.Create, FileAccess.Write)) { Thread.Sleep(1000); //Wait for any disk activity to stop. Integer[] d = new Integer[n]; for (int k=0; k<n; k++) { d[k] = new Integer((int)(rand.NextDouble()*k)); } start(); int max = 1000; int i = 0; while (i<max && elapsed()<10) { formatter.Serialize(fos, d); fos.Flush(); FlushFileBuffers(fos.Handle); // Forces the OS to flush i++; } double t =elapsed(); long f = fos.Length; Console.WriteLine( n +"\t"+ i + "\t"+ f / i +"\t"+ i / t +"\t"+ n * i / t); } } }
// Sets up member variables related to camera. private void SetUpCameraOutputs(int width, int height) { var cameraManager = (CameraManager)Context.GetSystemService(Context.CameraService); try { for (var i = 0; i < cameraManager.GetCameraIdList().Length; i++) { var cameraId = cameraManager.GetCameraIdList()[i]; CameraCharacteristics characteristics = cameraManager.GetCameraCharacteristics(cameraId); // We don't use a front facing camera in this sample. var facing = (Integer)characteristics.Get(CameraCharacteristics.LensFacing); if (facing != null && facing == (Integer.ValueOf((int)LensFacing.Front))) { continue; } var map = (StreamConfigurationMap)characteristics.Get(CameraCharacteristics.ScalerStreamConfigurationMap); if (map == null) { continue; } // For still image captures, we use the largest available size. Size largest = (Size)Collections.Max(Arrays.AsList(map.GetOutputSizes((int)ImageFormatType.Jpeg)), new Camera2Basic.CompareSizesByArea()); mImageReader = ImageReader.NewInstance(largest.Width, largest.Height, ImageFormatType.Jpeg, 2); mImageReader.SetOnImageAvailableListener(mOnImageAvailableListener, BackgroundHandler); var windowManager = Context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>(); // Find out if we need to swap dimension to get the preview size relative to sensor // coordinate. var displayRotation = windowManager.DefaultDisplay.Rotation; //noinspection ConstantConditions mSensorOrientation = (int)characteristics.Get(CameraCharacteristics.SensorOrientation); bool swappedDimensions = false; switch (displayRotation) { case SurfaceOrientation.Rotation0: case SurfaceOrientation.Rotation180: if (mSensorOrientation == 90 || mSensorOrientation == 270) { swappedDimensions = true; } break; case SurfaceOrientation.Rotation90: case SurfaceOrientation.Rotation270: if (mSensorOrientation == 0 || mSensorOrientation == 180) { swappedDimensions = true; } break; default: Log.Error("CameraPreview", "Display rotation is invalid: " + displayRotation); break; } Point displaySize = new Point(); windowManager.DefaultDisplay.GetSize(displaySize); var rotatedPreviewWidth = width; var rotatedPreviewHeight = height; var maxPreviewWidth = displaySize.X; var maxPreviewHeight = displaySize.Y; if (swappedDimensions) { rotatedPreviewWidth = height; rotatedPreviewHeight = width; maxPreviewWidth = displaySize.Y; maxPreviewHeight = displaySize.X; } if (maxPreviewWidth > MAX_PREVIEW_WIDTH) { maxPreviewWidth = MAX_PREVIEW_WIDTH; } if (maxPreviewHeight > MAX_PREVIEW_HEIGHT) { maxPreviewHeight = MAX_PREVIEW_HEIGHT; } // Danger, W.R.! Attempting to use too large a preview size could exceed the camera // bus' bandwidth limitation, resulting in gorgeous previews but the storage of // garbage capture data. mPreviewSize = ChooseOptimalSize(map.GetOutputSizes(Class.FromType(typeof(SurfaceTexture))), rotatedPreviewWidth, rotatedPreviewHeight, maxPreviewWidth, maxPreviewHeight, largest); // We fit the aspect ratio of TextureView to the size of preview we picked. var orientation = Resources.Configuration.Orientation; if (orientation == Android.Content.Res.Orientation.Landscape) { mTextureView.SetAspectRatio(mPreviewSize.Width, mPreviewSize.Height); } else { mTextureView.SetAspectRatio(mPreviewSize.Height, mPreviewSize.Width); } // Check if the flash is supported. var available = characteristics.Get(CameraCharacteristics.FlashInfoAvailable).JavaCast <Java.Lang.Boolean>(); if (available == null) { mFlashSupported = false; } else { mFlashSupported = (bool)available; } mCameraId = cameraId; return; } } catch (CameraAccessException e) { e.PrintStackTrace(); } catch (NullPointerException e) { // Currently an NPE is thrown when the Camera2API is used but not supported on the // device this code runs. //ErrorDialog.NewInstance(GetString(Resource.String.camera_error)).Show(ChildFragmentManager, FRAGMENT_DIALOG); Log.Error("CameraPreviewAlt", "SetUpCameraOutputs: " + e.ToString()); } }
public void Equal() { Assert.True(Integer.Int(5) == Integer.Int(5)); Assert.False(Integer.Int(7) == Integer.Int(5)); }
public void TestDeserializeStackItem() { StackItem stackItem1 = new ByteArray(new byte[5]); byte[] byteArray1 = StackItemSerializer.Serialize(stackItem1); StackItem result1 = StackItemSerializer.Deserialize(byteArray1, 1, (uint)byteArray1.Length); Assert.AreEqual(stackItem1, result1); StackItem stackItem2 = new VM.Types.Boolean(true); byte[] byteArray2 = StackItemSerializer.Serialize(stackItem2); StackItem result2 = StackItemSerializer.Deserialize(byteArray2, 1, (uint)byteArray2.Length); Assert.AreEqual(stackItem2, result2); StackItem stackItem3 = new Integer(1); byte[] byteArray3 = StackItemSerializer.Serialize(stackItem3); StackItem result3 = StackItemSerializer.Deserialize(byteArray3, 1, (uint)byteArray3.Length); Assert.AreEqual(stackItem3, result3); byte[] byteArray4 = StackItemSerializer.Serialize(1); byteArray4[0] = 0x40; Action action4 = () => StackItemSerializer.Deserialize(byteArray4, 1, (uint)byteArray4.Length); action4.Should().Throw <FormatException>(); List <StackItem> list5 = new List <StackItem> { 1 }; StackItem stackItem52 = new VM.Types.Array(list5); byte[] byteArray5 = StackItemSerializer.Serialize(stackItem52); StackItem result5 = StackItemSerializer.Deserialize(byteArray5, 1, (uint)byteArray5.Length); Assert.AreEqual(((VM.Types.Array)stackItem52).Count, ((VM.Types.Array)result5).Count); Assert.AreEqual(((VM.Types.Array)stackItem52).GetEnumerator().Current, ((VM.Types.Array)result5).GetEnumerator().Current); List <StackItem> list6 = new List <StackItem> { 1 }; StackItem stackItem62 = new Struct(list6); byte[] byteArray6 = StackItemSerializer.Serialize(stackItem62); StackItem result6 = StackItemSerializer.Deserialize(byteArray6, 1, (uint)byteArray6.Length); Assert.AreEqual(((Struct)stackItem62).Count, ((Struct)result6).Count); Assert.AreEqual(((Struct)stackItem62).GetEnumerator().Current, ((Struct)result6).GetEnumerator().Current); Dictionary <PrimitiveType, StackItem> list7 = new Dictionary <PrimitiveType, StackItem> { [2] = 1 }; StackItem stackItem72 = new Map(list7); byte[] byteArray7 = StackItemSerializer.Serialize(stackItem72); StackItem result7 = StackItemSerializer.Deserialize(byteArray7, 1, (uint)byteArray7.Length); Assert.AreEqual(((Map)stackItem72).Count, ((Map)result7).Count); Assert.AreEqual(((Map)stackItem72).Keys.GetEnumerator().Current, ((Map)result7).Keys.GetEnumerator().Current); Assert.AreEqual(((Map)stackItem72).Values.GetEnumerator().Current, ((Map)result7).Values.GetEnumerator().Current); }
public void TestDeserializeStackItem() { StackItem stackItem1 = new ByteString(new byte[5]); byte[] byteArray1 = BinarySerializer.Serialize(stackItem1, MaxItemSize); StackItem result1 = BinarySerializer.Deserialize(byteArray1, ExecutionEngineLimits.Default); Assert.AreEqual(stackItem1, result1); StackItem stackItem2 = new VM.Types.Boolean(true); byte[] byteArray2 = BinarySerializer.Serialize(stackItem2, MaxItemSize); StackItem result2 = BinarySerializer.Deserialize(byteArray2, ExecutionEngineLimits.Default); Assert.AreEqual(stackItem2, result2); StackItem stackItem3 = new Integer(1); byte[] byteArray3 = BinarySerializer.Serialize(stackItem3, MaxItemSize); StackItem result3 = BinarySerializer.Deserialize(byteArray3, ExecutionEngineLimits.Default); Assert.AreEqual(stackItem3, result3); byte[] byteArray4 = BinarySerializer.Serialize(1, MaxItemSize); byteArray4[0] = 0x40; Action action4 = () => BinarySerializer.Deserialize(byteArray4, ExecutionEngineLimits.Default); action4.Should().Throw <FormatException>(); List <StackItem> list5 = new List <StackItem> { 1 }; StackItem stackItem52 = new VM.Types.Array(list5); byte[] byteArray5 = BinarySerializer.Serialize(stackItem52, MaxItemSize); StackItem result5 = BinarySerializer.Deserialize(byteArray5, ExecutionEngineLimits.Default); Assert.AreEqual(((VM.Types.Array)stackItem52).Count, ((VM.Types.Array)result5).Count); Assert.AreEqual(((VM.Types.Array)stackItem52).GetEnumerator().Current, ((VM.Types.Array)result5).GetEnumerator().Current); List <StackItem> list6 = new List <StackItem> { 1 }; StackItem stackItem62 = new Struct(list6); byte[] byteArray6 = BinarySerializer.Serialize(stackItem62, MaxItemSize); StackItem result6 = BinarySerializer.Deserialize(byteArray6, ExecutionEngineLimits.Default); Assert.AreEqual(((Struct)stackItem62).Count, ((Struct)result6).Count); Assert.AreEqual(((Struct)stackItem62).GetEnumerator().Current, ((Struct)result6).GetEnumerator().Current); StackItem stackItem72 = new Map { [2] = 1 }; byte[] byteArray7 = BinarySerializer.Serialize(stackItem72, MaxItemSize); StackItem result7 = BinarySerializer.Deserialize(byteArray7, ExecutionEngineLimits.Default); Assert.AreEqual(((Map)stackItem72).Count, ((Map)result7).Count); CollectionAssert.AreEqual(((Map)stackItem72).Keys.ToArray(), ((Map)result7).Keys.ToArray()); CollectionAssert.AreEqual(((Map)stackItem72).Values.ToArray(), ((Map)result7).Values.ToArray()); }
internal MaskBuilder Mask(Type t, Integer i) { map.put(t, i); return this; }
public object Test(Integer i) { return(-i); }
public static bool TryRebuildDirtyRegionsAndRooms2(RegionAndRoomUpdater __instance) { //if (working || !Enabled) // return; if (!__instance.Enabled) { return(false); } if (getThreadRebuilding()) { return(false); } //working = true; setThreadRebuilding(true); if (!initialized(__instance)) { lock (initializingLock) { if (!initialized(__instance)) { __instance.RebuildAllRegionsAndRooms(); } initialized(__instance) = true; } } if (RegionDirtyer_Patch.get_DirtyCells(map(__instance).regionDirtyer).IsEmpty) { //working = false; setThreadRebuilding(false); return(false); } try { int tid = Thread.CurrentThread.ManagedThreadId; //HashSet<int> gate1ThreadSet = getGate1ThreadSet(__instance); //gate1ThreadSet.Add(tid); Integer gate1Count = getGate1Count(__instance); int gate1Ticket = Interlocked.Increment(ref gate1Count.integer); EventWaitHandle gate1WaitHandle = getGate1WaitHandle(__instance); gate1WaitHandle.WaitOne(); //EventWaitHandle gate2WaitHandle = getGate2WaitHandle(__instance); //gate2WaitHandle.Reset(); if (gate1Ticket == 1) { RegenerateNewRegionsFromDirtyCells2(__instance); CreateOrUpdateRooms2(__instance); if (DebugSettings.detectRegionListersBugs) { Autotests_RegionListers.CheckBugs(map(__instance)); } newRegions(__instance).Clear(); gate1WaitHandle.Reset(); } //HashSet<int> gate2ThreadSet = getGate2ThreadSet(__instance); //gate2ThreadSet.Add(tid); Integer gate2Count = getGate2Count(__instance); Interlocked.Increment(ref gate2Count.integer); int gate1Remaining = Interlocked.Decrement(ref gate1Count.integer); EventWaitHandle gate2WaitHandle = getGate2WaitHandle(__instance); if (gate1Remaining == 0) { //CreateOrUpdateRooms2(__instance); /* * HashSet<IntVec3> oldDirtyCells = getOldDirtyCells(__instance); * foreach(IntVec3 oldDirtyCell in oldDirtyCells) * { * map(__instance).temperatureCache.ResetCachedCellInfo(oldDirtyCell); * } */ //if (DebugSettings.detectRegionListersBugs) //{ //Autotests_RegionListers.CheckBugs(map(__instance)); //} //newRegions(__instance).Clear(); gate2WaitHandle.Set(); } gate2WaitHandle.WaitOne(); int gate2Remaining = Interlocked.Decrement(ref gate2Count.integer); if (gate2Remaining == 0) { gate2WaitHandle.Reset(); gate1WaitHandle.Set(); } } catch (Exception arg) { Log.Error("Exception while rebuilding dirty regions: " + arg); } //newRegions.Clear(); //map.regionDirtyer.SetAllClean(); //initialized = true; //Moved to earlier code above //working = false; setThreadRebuilding(false); return(false); }
public void Plus() { var value = Integer.Int(5) + Integer.Int(7); Assert.Equal(12, value.ToDouble()); }
public void Min(double result, int a, int b) { var value = Integer.Min(Integer.Int(a), Integer.Int(b)); Assert.Equal(result, value.ToDouble()); }
public void Int() { var value = Integer.Int(7); Assert.Equal(7, value.ToDouble()); }
public void Floored_Fraction() { var value = Integer.Floored(5.5); Assert.Equal(5, value.ToDouble()); }
public void Floored_Int() { var value = Integer.Floored(5); Assert.Equal(5, value.ToDouble()); }
public void IntToString() { Assert.Equal("1234", Integer.Int(1234).ToString()); }
public void NotEqual() { Assert.True(Integer.Int(7) != Integer.Int(5)); Assert.False(Integer.Int(5) != Integer.Int(5)); }
public Asdu(TLV tlv) : this() { Bytes = tlv.Bytes; ByteArraySegment pdu = tlv.Value.Bytes; pdu.Length = 0; TLV tmp = new TLV(pdu.EncapsulatedBytes()); svID = new VisibleString(tmp); pdu.Length += tmp.Bytes.Length; tmp = new TLV(pdu.EncapsulatedBytes()); if (IsDatset(tmp)) { datset = new VisibleString(tmp); pdu.Length += tmp.Bytes.Length; tmp = new TLV(pdu.EncapsulatedBytes()); } smpCnt = new Integer(tmp); pdu.Length += tmp.Bytes.Length; tmp = new TLV(pdu.EncapsulatedBytes()); confRev = new Integer(tmp); pdu.Length += tmp.Bytes.Length; tmp = new TLV(pdu.EncapsulatedBytes()); if (IsRefrTm(tmp)) { refrTm = new UtcTime(tmp); pdu.Length += tmp.Bytes.Length; tmp = new TLV(pdu.EncapsulatedBytes()); } smpSynch = new TAsn1.Boolean(tmp); pdu.Length += tmp.Bytes.Length; tmp = new TLV(pdu.EncapsulatedBytes()); if (!smpSynch.Value) { smpRate = new TAsn1.Boolean(tmp); pdu.Length += tmp.Bytes.Length; tmp = new TLV(pdu.EncapsulatedBytes()); } tmp = new TLV(pdu.EncapsulatedBytes()); ByteArraySegment chn = tmp.Value.Bytes; chn.Length = Channel.ChannelLength; sample.Add(new Channel(chn)); // Confirm the loop while (chn.Length + chn.Offset < chn.BytesLength) { chn = chn.EncapsulatedBytes(); chn.Length = Channel.ChannelLength; sample.Add(new Channel(chn)); } }
protected override void sendJoinRequest() { Console.WriteLine(""); Console.WriteLine("-------------------------------------------"); Console.WriteLine("| <<< Join Calendar Network procedure >>> |"); Console.WriteLine("-------------------------------------------"); Console.Write("Please enter the IPv4 address of a know host that is a member of the calendar network currently : "); String ipAddress = Reader.nextIPv4(); Console.Write("Please enter the port number of the host that you have entered its IP address [" + ipAddress + "] : "); int port = Reader.nextInt(1025, 65535); try{ HostUrl hostUrl = new HostUrl(port, ipAddress); //Set the destination host based on what the user entered if (setDestinationHost(hostUrl)) { String thisHostIPv4; String thisHostUrl; int thisHostPort; try { thisHostIPv4 = LocalNet.IpAddress; //Generate the ipv4 address of this machine thisHostUrl = "http://" + thisHostIPv4 + "/"; //Generate the Url of this machine based on its Ip thisHostPort = HostsList.getFirstHostUrl().getPort(); //find out the current machine port if (thisHostIPv4.Equals(ipAddress) && thisHostPort == port) { Console.WriteLine("You can not connect to yourself.\nThe IP address and the port number that you have entered is blonged to this machine."); return; } host.MethodName = "CalendarNetwork.joinRequest"; host.Params.Clear(); host.Params.Add(thisHostUrl); host.Params.Add(thisHostPort); ServerStatus.signOnServer(); //if the joining fail it must change to signoff again //String hostsListString = (String) host.execute("CalendarNetwork.joinRequest", params); //joinRequest function is placed in HostList.java file response = host.Send(hostUrlAddress); String hostsListString = (String)response.Value; // if (hostsListString == null) { Console.WriteLine("The joining process was failed on the known host that you have introduced."); ServerStatus.signOffServer(); //because the joining fail it must change to signoff again return; } else { String[] lines = hostsListString.Split("\n".ToCharArray()); if (lines[0].Equals("true")) { HostsList.addHost(hostUrl);//At first Add the known host to the hostList of this machine after a successful connection } else { Console.WriteLine("The joining process was failed on the known host that you have introduced."); ServerStatus.signOffServer(); //because the joining fail it must change to signoff again return; } //sending new request to synchronize the appointments' list this.synchronizeDataBase(hostUrl); Console.WriteLine("The synchronizing stage has finished.\nNow we register this host on other hosts!"); String nextHostUrl, nextHostPort; bool result = false; //host.MethodName = "CalendarNetwork.addMe"; //Added in C# for (int index = 1; index < lines.Length; index++) { nextHostUrl = null; nextHostPort = null; //The response must be parse and other hosts come out from the String and propagate the current machine on all of them //Must parse each address and send requests separately //At first find the url of the next host Regex regex = null; Match matcher = null; regex = new Regex("URL:\\[(.*?)\\]"); matcher = regex.Match(lines[index]); if (matcher.Success) { nextHostUrl = matcher.Groups[1].Value; } //Then find the port number string regex = new Regex("Port:\\[(.*?)\\]"); matcher = regex.Match(lines[index]); if (matcher.Success) { nextHostPort = matcher.Groups[1].Value; } //Now connect to the next host and register if (nextHostUrl != null && nextHostPort != null) { hostUrl = new HostUrl(nextHostUrl, Integer.parseInt(nextHostPort)); //Set the destination host based on what the user entered if (setDestinationHost(hostUrl)) { host.MethodName = "CalendarNetwork.addMe"; host.Params.Clear(); host.Params.Add(thisHostUrl); host.Params.Add(thisHostPort); try { response = host.Send(hostUrlAddress); result = (bool)response.Value; if (result) { HostsList.addHost(hostUrl);//Add next host of the list to the hostList of this machine } else { Console.WriteLine("Registeration of the current machine has failed on the host : [" + hostUrl.getFullUrl() + "]"); } } catch (System.Exception e) { Console.WriteLine("Registeration of the current machine has failed on the host : [" + hostUrl.getFullUrl() + "]"); Console.WriteLine(e.Message); } } } } //End of for } //End of else } catch (Exception e) { Console.WriteLine(e.Message); } } } catch (Exception e) { Console.WriteLine(e.Message); } }
private Date loadLocalDatabase() { //Read the current database at the starting time to initiate the appointmentList Date lastModifiedDate = null; Regex regex = null; Match matcher = null; try { List <String> lines = this.databaseFile.readFile(); if (lines != null) { regex = new Regex(" HPN Calendar Network Version TUMS "); if (lines.Count > 0 && regex.IsMatch(lines[0])) //Recognize the file header { if (lines.Count > 3) { //Extracting second line : Modification dateTime regex = new Regex("Modify:&@\\[(.*?)\\]#!"); matcher = regex.Match(lines[2]); if (matcher.Success) { String lastModificationString = matcher.Groups[1].Value; lastModifiedDate = new Date(lastModificationString, DateString.Format); } regex = new Regex("SequentialNum:&@\\[(.*?)\\]#!"); matcher = regex.Match(lines[4]); if (matcher.Success) { try { String SequentialNum = matcher.Groups[1].Value; int seqNumber = Integer.parseInt(SequentialNum); SequentialNumber.setNextSequentialNumber(seqNumber); } catch (Exception e) { Console.WriteLine(e.Message); } } String seqNum, header, date, time, duration, comment; for (int index = 8; index < lines.Count; index += 2) { String line = lines[index]; seqNum = null; header = null; date = null; time = null; duration = null; comment = null; // regex = new Regex("SeqNum:&@\\[(.*?)\\]#!"); matcher = regex.Match(line); if (matcher.Success) { seqNum = matcher.Groups[1].Value; } // regex = new Regex("Header:&@\\[(.*?)\\]#!"); matcher = regex.Match(line); if (matcher.Success) { header = matcher.Groups[1].Value; } // regex = new Regex("Date:&@\\[(.*?)\\]#!"); matcher = regex.Match(line); if (matcher.Success) { date = matcher.Groups[1].Value; } // regex = new Regex("Time:&@\\[(.*?)\\]#!"); matcher = regex.Match(line); if (matcher.Success) { time = matcher.Groups[1].Value; } // regex = new Regex("Duration:&@\\[(.*?)\\]#!"); matcher = regex.Match(line); if (matcher.Success) { duration = matcher.Groups[1].Value; } // regex = new Regex("Comment:&@\\[(.*?)\\]#!"); matcher = regex.Match(line); if (matcher.Success) { comment = matcher.Groups[1].Value; } if (seqNum != null && header != null && date != null && time != null && duration != null && comment != null) { try { Integer seqNumber = new Integer(seqNum); Integer secDuration = new Integer(duration); Date dateTime = new Date(date + " " + time, DateString.Format); SequentialNumber sqn = new SequentialNumber(seqNumber.intValue()); Appointment appointment = new Appointment(sqn, dateTime, secDuration.intValue(), header, comment); this.addDatabaseAppointment(appointment); } catch (System.Exception e) { Console.WriteLine(e.Message); } } } //End for } } } } catch (System.IO.IOException e) { Console.WriteLine("Problem in reading from database file : " + e.Message); } return(lastModifiedDate); }
public SemanticAtom Visit(Integer n) { n.RealizedType = Primitive.Int; return(n.RealizedType); }
public static Boolean IsSurrogatePair(String s, Integer index) { return null; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_zones); var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.Title = GetString(Resource.String.zones); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); // initializing widget mChart = this.FindViewById <FlexChart>(Resource.Id.zonesFlexchart); mChart.BindingX = "Number"; mChart.ChartType = ChartType.Scatter; int nStudents = 20; int nMaxPoints = 100; IList <object> data = ZonesData.getZonesList(nStudents, nMaxPoints); mChart.ItemsSource = data; mChart.Tapped += MChart_Tapped; mChart.AxisX.Title = "student number"; mChart.AxisY.Title = "student accumulated points"; double mean = this.FindMean(data); double stdDev = this.FindStdDev(data, mean); List <double> scores = new List <double>(); foreach (ZonesData item in data) { scores.Add(item.Score); } scores.Sort((x, y) => y.CompareTo(x)); var zones = new double[] { scores[this.GetBoundingIndex(scores, 0.85)], scores[this.GetBoundingIndex(scores, 0.75)], scores[this.GetBoundingIndex(scores, 0.25)], scores[this.GetBoundingIndex(scores, 0.05)] }; Integer[] colors = new Integer[] { new Integer(Color.Argb(255, 255, 192, 192)), new Integer(Color.Argb(255, 55, 228, 228)), new Integer(Color.Argb(255, 255, 228, 128)), new Integer(Color.Argb(255, 128, 255, 128)), new Integer(Color.Argb(255, 128, 128, 255)), }; for (var i = 4; i >= 0; i--) { float y = (float)(i == 4 ? mean + 2 * stdDev : zones[i]); PointF[] sdata = new PointF[data.Count]; for (int j = 0; j < data.Count; j++) { sdata[j] = new PointF(j, y); if (i == 0) { System.Console.WriteLine(j + "=" + y); } } string seriesName = ((char)((short)'A' + 4 - i)).ToString(); var series = new ChartSeries(); series.Chart = mChart; series.SeriesName = seriesName; series.Binding = "Y"; series.ItemsSource = sdata; series.BindingX = "X"; series.ChartType = ChartType.Area; series.Style = new ChartStyle(); series.Style.Fill = new Color(colors[i].IntValue()); mChart.Series.Add(series); } ChartSeries scoreSeries = new ChartSeries(); scoreSeries.Chart = mChart; scoreSeries.SeriesName = "raw score"; scoreSeries.Binding = "Score"; scoreSeries.BindingX = "Number"; mChart.Series.Add(scoreSeries); for (var i = -2; i <= 2; i++) { var y = mean + i * stdDev; string seriesName = string.Empty; if (i > 0) { seriesName = "m+" + i + "s"; } else if (i < 0) { seriesName = "m" + i + "s"; } else { seriesName = "mean"; } PointF[] sdata = new PointF[data.Count]; for (int j = 0; j < data.Count; j++) { sdata[j] = new PointF(j, (float)y); } var series = new ChartSeries(); series.Chart = mChart; series.SeriesName = seriesName; series.Binding = "Y"; series.ItemsSource = sdata; series.BindingX = "X"; series.ChartType = ChartType.Line; series.Style = new ChartStyle(); series.Style.StrokeThickness = 2; series.Style.Stroke = Color.Rgb(0x20, 0x20, 0x20); mChart.Series.Add(series); } }
public static Boolean IsUpper(String s, Integer index) { return null; }
public CMyFleet(Integer FlottenID) { }
protected Texture initializeTexture(DrawContext dc, Object imageSource) { if (dc == null) { String message = Logging.getMessage("nullValue.DrawContextIsNull"); Logging.logger().severe(message); throw new IllegalStateException(message); } if (this.textureInitializationFailed) { return(null); } Texture t; bool haveMipMapData; GL gl = dc.getGL(); if (imageSource is String) { String path = (String)imageSource; Object streamOrException = WWIO.getFileOrResourceAsStream(path, this.GetType()); if (streamOrException == null || streamOrException is Exception) { Logging.logger().log(java.util.logging.Level.SEVERE, "generic.ExceptionAttemptingToReadImageFile", streamOrException != null ? streamOrException : path); this.textureInitializationFailed = true; return(null); } try { TextureData td = OGLUtil.newTextureData(gl.getGLProfile(), (InputStream)streamOrException, this.useMipMaps); t = TextureIO.newTexture(td); haveMipMapData = td.getMipmapData() != null; } catch (Exception e) { String msg = Logging.getMessage("layers.TextureLayer.ExceptionAttemptingToReadTextureFile", imageSource); Logging.logger().log(java.util.logging.Level.SEVERE, msg, e); this.textureInitializationFailed = true; return(null); } } else if (imageSource is BufferedImage) { try { TextureData td = AWTTextureIO.newTextureData(gl.getGLProfile(), (BufferedImage)imageSource, this.useMipMaps); t = TextureIO.newTexture(td); haveMipMapData = td.getMipmapData() != null; } catch (Exception e) { String msg = Logging.getMessage("generic.IOExceptionDuringTextureInitialization"); Logging.logger().log(java.util.logging.Level.SEVERE, msg, e); this.textureInitializationFailed = true; return(null); } } else if (imageSource is URL) { try { InputStream stream = ((URL)imageSource).openStream(); if (stream == null) { Logging.logger().log(java.util.logging.Level.SEVERE, "generic.ExceptionAttemptingToReadImageFile", imageSource); this.textureInitializationFailed = true; return(null); } TextureData td = OGLUtil.newTextureData(gl.getGLProfile(), stream, this.useMipMaps); t = TextureIO.newTexture(td); haveMipMapData = td.getMipmapData() != null; } catch (Exception e) { String msg = Logging.getMessage("layers.TextureLayer.ExceptionAttemptingToReadTextureFile", imageSource); Logging.logger().log(java.util.logging.Level.SEVERE, msg, e); this.textureInitializationFailed = true; return(null); } } else { Logging.logger().log(java.util.logging.Level.SEVERE, "generic.UnrecognizedImageSourceType", imageSource.GetType().Name); this.textureInitializationFailed = true; return(null); } if (t == null) // In case JOGL TextureIO returned null { Logging.logger().log(java.util.logging.Level.SEVERE, "generic.TextureUnreadable", imageSource is String ? imageSource : imageSource.GetType().Name); this.textureInitializationFailed = true; return(null); } // Textures with the same path are assumed to be identical textures, so key the texture id off the // image source. dc.getTextureCache().put(imageSource, t); t.bind(gl); // Enable the appropriate mip-mapping texture filters if the caller has specified that mip-mapping should be // enabled, and the texture itself supports mip-mapping. bool useMipMapFilter = this.useMipMaps && (haveMipMapData || t.isUsingAutoMipmapGeneration()); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, useMipMapFilter ? GL.GL_LINEAR_MIPMAP_LINEAR : GL.GL_LINEAR); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE); if (this.isUseAnisotropy() && useMipMapFilter) { double maxAnisotropy = dc.getGLRuntimeCapabilities().getMaxTextureAnisotropy(); if (dc.getGLRuntimeCapabilities().isUseAnisotropicTextureFilter() && maxAnisotropy >= 2.0) { gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)maxAnisotropy); } } this.width = t.getWidth(); this.height = t.getHeight(); this.texCoords = t.getImageTexCoords(); return(t); }
public void Visit(Integer integer, byte data) => buffer.WriteMultiByteValue(index, integer.Length, currentChange, 0);
protected override bool synchronizeDataBase(HostUrl hostUrl) { //called in sendJoinRequest() to get the latest appointments from the known host if (this.setDestinationHost(hostUrl)) { Date lmDate = new Date(); lmDate.resetTime(); if (calendar.getLastModified() != null) { lmDate = calendar.getLastModified(); } //Object[] params = new Object[]{dates}; host.MethodName = "Calendar.syncRequest"; host.Params.Clear(); host.Params.Add(lmDate.ToString()); try { Console.WriteLine("Appointments Syncronization has started ...."); response = host.Send(hostUrlAddress); String appointmentLists = (String)response.Value; if (appointmentLists == null) { Console.WriteLine("There is no appointment for synchronization."); } else { String[] lines = appointmentLists.Split("\n".ToCharArray()); Regex regex = null; Match matcher = null; //Set the main seqnum at the current machine! if (lines.Length > 0) { try { regex = new Regex("SequentialNum:&@\\[(.*?)\\]#!"); matcher = regex.Match(lines[0]); if (matcher.Success) { String mainSeqNumString = matcher.Groups[1].Value; SequentialNumber.setNextSequentialNumber(Integer.parseInt(mainSeqNumString)); Console.WriteLine("The sequential number has been synchronized successfully."); } else { Console.WriteLine("Couldn't synchronize the sequential number."); } } catch (Exception e) { Console.WriteLine("Couldn't synchronize the sequential number."); Console.WriteLine(e.Message); } } calendar.clearAllAppointments(); String seqNum, header, date, time, duration, comment; int counter = 0; int counterFailed = 0; for (int index = 1; index < lines.Length; index++) { try { seqNum = null; header = null; date = null; time = null; duration = null; comment = null; // regex = new Regex("SeqNum:&@\\[(.*?)\\]#!"); matcher = regex.Match(lines[index]); if (matcher.Success) { seqNum = matcher.Groups[1].Value; } // regex = new Regex("Header:&@\\[(.*?)\\]#!"); matcher = regex.Match(lines[index]); if (matcher.Success) { header = matcher.Groups[1].Value; } // regex = new Regex("Date:&@\\[(.*?)\\]#!"); matcher = regex.Match(lines[index]); if (matcher.Success) { date = matcher.Groups[1].Value; } // regex = new Regex("Time:&@\\[(.*?)\\]#!"); matcher = regex.Match(lines[index]); if (matcher.Success) { time = matcher.Groups[1].Value; } // regex = new Regex("Duration:&@\\[(.*?)\\]#!"); matcher = regex.Match(lines[index]); if (matcher.Success) { duration = matcher.Groups[1].Value; } // regex = new Regex("Comment:&@\\[(.*?)\\]#!"); matcher = regex.Match(lines[index]); if (matcher.Success) { comment = matcher.Groups[1].Value; } if (seqNum != null && header != null && date != null && time != null && duration != null && comment != null) { Integer seqNumber = new Integer(seqNum); Integer secDuration = new Integer(duration); Date dateTime = new Date(date + " " + time, DateString.Format); SequentialNumber sqn = new SequentialNumber(seqNumber.intValue()); Appointment appointment = new Appointment(sqn, dateTime, secDuration.intValue(), header, comment); calendar.addAppointment(appointment); counter++; } } catch (Exception) { counterFailed++; } }//end for if (counterFailed > 0) { Console.WriteLine(counterFailed + " numbers of the received appointment in synchronization has failed to add."); } if (counter == 1) { Console.WriteLine("The appointment list has been updated.\n" + counter + " appointment has been added or updated."); } else if (counter > 1) { Console.WriteLine("The appointment list has been updated.\n" + counter + " appointments have been added or updated."); } }//end if } catch (Exception e) { Console.WriteLine(e.Message); } } return(false); }
public void Minus() { var value = Integer.Int(5) - Integer.Int(7); Assert.Equal(-2, value.ToDouble()); }
//@Override public bool addNewAppointment(int seqNumberInt, String dateTimeString, int secDurationInt, String header, String comment) { //call by other clients to send a new appointment //because in C# XmlRpcServer Library stoping the servicing has an error we refuse the incoming requests if the server //is not in its online mode. if (!ServerStatus.getServerStatus()) { return(false); } Integer seqNumber; Date dateTime; Integer secDuration; try { seqNumber = new Integer(seqNumberInt); dateTime = new Date(dateTimeString); secDuration = new Integer(secDurationInt); } catch (System.Exception) { //Console.WriteLine("\nOne request for adding a new appointment to the current system has received but in converting the data in has crashed by the following exception : "); //Console.WriteLine("Exception Message : \n" + e.Message); //Console.WriteLine("Received Data : " + "\nSeqential Number : " + seqNumberInt + "\nDate : " + dateTimeString + "\nDuration " + secDurationInt + "\nHeader" + header + "\nComment" + comment); return(false); } if (seqNumber.intValue() < 1) { //because it will called by remote host throwing exception is meaning less. //throw new System.ArgumentOutOfRangeException("The sequential number[seqNumber] must be greater than 0."); //Console.WriteLine("\nOne request for adding a new appointment to the current system has received but the sequential number was invalid."); //Console.WriteLine("Received Data : " + "\nSeqential Number : " + seqNumberInt + "\nDate : " + dateTimeString + "\nDuration " + secDurationInt + "\nHeader" + header + "\nComment" + comment); return(false); } else if (secDuration.intValue() < 1) { //throw new System.ArgumentOutOfRangeException("The seconds of duration[secDuration] must be greater than 0."); //Console.WriteLine("\nOne request for adding a new appointment to the current system has received but the duration number was invalid."); //Console.WriteLine("Received Data : " + "\nSeqential Number : " + seqNumberInt + "\nDate : " + dateTimeString + "\nDuration " + secDurationInt + "\nHeader" + header + "\nComment" + comment); return(false); } //Create requested sequence number or a new sequence number and add the appointment to the array list. try { //We make the sequential number and then check for its existance //if the sequential number is exist then we make a new one and it will continue till get a unique sequential number //another strategy for here can be to return false if we have the current sequential number in this host //but we think it is better to not lose any apointment even with registering it with a wrong sequential number //but based on what said in the assignment sheet //we must not consider the conflict of the concurrency of the creation of appointments SequentialNumber sqn = new SequentialNumber(seqNumber.intValue()); bool flag; do { flag = false; foreach (Appointment tempAppointment in this.appointmentsList) //search to sure about non existence of the new sequence number in appointment list { if (tempAppointment.getSequentialNumber() == sqn.getSequentialNumber()) { sqn = new SequentialNumber(); flag = true; break; } } }while(flag); if (sqn.getSequentialNumber() != seqNumber.intValue()) { Console.WriteLine("Remote addAppointment: The sequance number [" + seqNumber.intValue() + "] that has been sent by a remote host, is exist. So a new sequance number has assigned : " + sqn.getSequentialNumber()); } Appointment appointment = new Appointment(sqn, dateTime, secDuration.intValue(), header, comment); this.appointmentsList.Add(appointment); if (this.appointmentsList.Exists(temp => temp == appointment)) //if the add was successful? { //This will show when a far host add an appointment to the list //Console.WriteLine(""); //Console.WriteLine("_______________________________"); //Console.WriteLine("One appointment has been added."); //Console.WriteLine("-------------------------------"); //Console.WriteLine(appointment.ToString()); this.setLastModified(); this.updateLocalDatabase(); return(true); } else { return(false); } } catch (System.IndexOutOfRangeException) //for creating sequential number { //Console.WriteLine(e.Message); return(false); } }
public static CUrl Planet(Integer PlanetID) { return null; }
public static CUrl Ship(Integer ShipID) { return null; }
public static Boolean IsSymbol(String s, Integer index) { return null; }
public static IGuiControl InsertCell(IGuiControl row, Integer Index) { return null; }
public static Boolean IsWhiteSpace(String s, Integer index) { return null; }
public static void SetColumnSpan(IGuiControl Cell, Integer Value) { }
public void Less() { Assert.True(Integer.Int(5) < Integer.Int(7)); Assert.False(Integer.Int(5) < Integer.Int(5)); Assert.False(Integer.Int(7) < Integer.Int(5)); }
internal void assertEquals(int expected, Integer actual) { Util.LuceneTestCase.assertEquals(expected, actual.value); }
public static CUrl Script(Integer ScriptID) { return null; }
public void Default() { var value = new Integer(); Assert.Equal(0, value.ToDouble()); }
static void Main() { Intro(); Integer[] numbers = new Integer[ARRAY_SIZE]; for (int i = 0; i < ARRAY_SIZE; i++ ) { Integer number = new Integer(i); numbers[i] = number; } for (int i = 0; i < ARRAY_SIZE; i++ ) { int number = numbers[i].GetValue(); Console.WriteLine("The value of Integer[{0}] is {1}.", i, number); } End(); }
public void LessEqual() { Assert.True(Integer.Int(5) <= Integer.Int(7)); Assert.True(Integer.Int(5) <= Integer.Int(5)); Assert.False(Integer.Int(7) <= Integer.Int(5)); }
public static void MergeRow(IGuiControl row, Integer Start) { }
public void GreaterEqual() { Assert.True(Integer.Int(7) >= Integer.Int(5)); Assert.True(Integer.Int(5) >= Integer.Int(5)); Assert.False(Integer.Int(5) >= Integer.Int(7)); }
/// <summary> Sets the number of columns in the given table to the givne integer. </summary> /// <param name="Table">Table, in which the number of columns should be changed.</param> /// <param name="Value">Number of columns the table should have afterwards.</param> public static void SetTableColumnCount(IGuiControl Table, Integer Value) { }
internal EndNode(Unit unit, Unit unit2, float num) : base(num) { this.baseUnit = unit; this.leftContext = unit2; this.key = Integer.valueOf(unit.getBaseID() * 121 + this.leftContext.getBaseID()); }