Search Results

Search found 501 results on 21 pages for 'sequential'.

Page 3/21 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • In C# is there a function that correlates sequential values on a IEnumerable

    - by Mike Q
    Hi all, I have a IEnumerable. I have a custom Interval class which just has two DateTimes inside it. I want to convert the IEnumerable to IEnumerable where n DateTimes would enumerate to n-1 Intervals. So if I had 1st Jan, 1st Feb and 1st Mar as the DateTime then I want two intervals out, 1st Jan/1st Feb and 1st Feb/1st March. Is there an existing C# Linq function that does this. Something like the below Correlate... IEnumerable<Interval> intervals = dttms.Correlate<DateTime, Interval>((dttm1, dttm2) => new Interval(dttm1, dttm2)); If not I'll just roll my own.

    Read the article

  • model binding of non-sequential arrays

    - by user281180
    I am having a table in which i`m dynamically creating and deleting rows. How can I change the code such that the rows be added and deleted and the model info property filled accordingly. Bearing in mind that the rows can be dynamically created and deleted, I may have Info[0], Inf0[3], info[4]... My objective is to be able to bind the array even if it`s not in sequence. Model public class Person { public int[] Size { get; set; } public string[] Name { get; set; } public Info[]info { get; set; } } public class Info { public string Address { get; set; } public string Tel { get; set; } View <script type="text/javascript" language="javascript"> $(function () { var count = 1; $('#AddSize').live('click', function () { $("#divSize").append('</br><input type="text" id="Size" name="Size" value=""/><input type = "button" id="AddSize" value="Add"/>'); }); $('#AddName').live('click', function () { $("#divName").append('</br><input type="text" id="Name" name="Name" value=""/><input type = "button" id="AddName" value="Add"/>'); }); $('#AddRow').live('click', function () { $('#details').append('<tr><td>Address</td><td> <input type="text" name="Info[' + count + '].Address"/></td><td>Tel</td><td><input type="text" name="Info[' + count++ + '].Tel"/></td> <td><input type="button" id="AddRow" value="Add"/> </td></tr>'); }); }); </script> </head> <body> <form id="closeForm" action="<%=Url.Action("Create",new{Action="Create"}) %>" method="post" enctype="multipart/form-data"> <div id="divSize"> <input type="text" name="Size" value=""/> <input type="button" value="Add" id="AddSize" /> </div> <div id="divName"> <input type="text" name="Name" value=""/> <input type="button" value="Add" id="AddName" /> </div> <div id="Tab"> <table id="details"> <tr><td>Address</td><td> <input type="text" name="Info[0].Address"/></td><td>Tel</td><td><input type="text" name="Info[0].Tel"/></td> <td><input type="button" id="AddRow" value="Add"/> </td></tr> </table> </div> <input type="submit" value="Submit" /> </form> </body> } Controller public ActionResult Create(Person person) { return new EmptyResult(); }

    Read the article

  • Sequential searching with sorted linked lists

    - by John Graveston
    struct Record_node* Sequential_search(struct Record_node *List, int target) { struct Record_node *cur; cur = List->head ; if(cur == NULL || cur->key >= target) { return NULL; } while(cur->next != NULL) { if(cur->next->key >= target) { return cur; } cur = cur->next; } return cur; } I cannot interpret this pseudocode. Can anybody explain to me how this program works and flows? Given this pseudocode that searches for a value in a linked list and a list that is in an ascending order, what would this program return? a. The largest value in the list that is smaller than target b. The largest value in the list that is smaller than or same as target c. The smallest value in the list that is larger than or same as target d. Target e. The smallest value in the list that is larger than target And say that List is [1, 2, 4, 5, 9, 20, 20, 24, 44, 69, 70, 71, 74, 77, 92] and target 15, how many comparisons are occurred? (here, comparison means comparing the value of target)

    Read the article

  • Updating Workflow Task without Correlation Token

    - by Khurram Aziz
    I have inhertied a sequential sharepoint workflow which deals with multiple tasks for different people; multi step approval based on certain condition..For each approval new task is created and monitored...For some reason; we have decided to use single task for the whole workflow and the single task will get assigned to required person at different stages...this will help us reduce the cluter in the task list For refactoring it; I am trying to create "CreateOrUpdateTaskAndWaitForCompletition" activity...so that I can use this component multiple times as per given workflow. Create/Wait branch of my activity works fine; as I have the correlation token within the activity. But when I try two instances of this activity; task is created in first activity and it needs to be updated in second instance where I dont have the correlation token. In the second instance; (Update/Wait branch) I have tried updating the task through code activity but its not working and I am getting "This task is currently locked by a running workflow and cannot be edited" exception! Can I use UpdateTask activity without correlation token? Can I programmatically update the workflow task? Can I programmatically unlock the workflow task?

    Read the article

  • A couple of questions about NHibernate's GuidCombGenerator

    - by Eyvind
    The following code can be found in the NHibernate.Id.GuidCombGenerator class. The algorithm creates sequential (comb) guids based on combining a "random" guid with a DateTime. I have a couple of questions related to the lines that I have marked with *1) and *2) below: private Guid GenerateComb() { byte[] guidArray = Guid.NewGuid().ToByteArray(); // *1) DateTime baseDate = new DateTime(1900, 1, 1); DateTime now = DateTime.Now; // Get the days and milliseconds which will be used to build the byte string TimeSpan days = new TimeSpan(now.Ticks - baseDate.Ticks); TimeSpan msecs = now.TimeOfDay; // *2) // Convert to a byte array // Note that SQL Server is accurate to 1/300th of a millisecond so we divide by 3.333333 byte[] daysArray = BitConverter.GetBytes(days.Days); byte[] msecsArray = BitConverter.GetBytes((long) (msecs.TotalMilliseconds / 3.333333)); // Reverse the bytes to match SQL Servers ordering Array.Reverse(daysArray); Array.Reverse(msecsArray); // Copy the bytes into the guid Array.Copy(daysArray, daysArray.Length - 2, guidArray, guidArray.Length - 6, 2); Array.Copy(msecsArray, msecsArray.Length - 4, guidArray, guidArray.Length - 4, 4); return new Guid(guidArray); } First of all, for *1), wouldn't it be better to have a more recent date as the baseDate, e.g. 2000-01-01, so as to make room for more values in the future? Regarding *2), why would we care about the accuracy for DateTimes in SQL Server, when we only are interested in the bytes of the datetime anyway, and never intend to store the value in an SQL Server datetime field? Wouldn't it be better to use all the accuracy available from DateTime.Now?

    Read the article

  • Setting ModerationInformation.Status from Approved back to pending removes

    - by Gavin Morgan
    Seeing if anyone else has had this problem and a resolution to it. I have a visual studio sequential workflow on a list (not a library) which does NOT use tasks, the approval process is done through the Approve/Reject OOTB buttons on the list item. The approval is a 2 stage approval, whereby if the 1st stage is completed (via clicking the Approve OOTB button), i reset the ModerationInformation.Status from Approved back to pending then send an email to the 2nd stage approver. My problem is, when i set the the ModerationInformation.Status back to Pending from Approved so there is never an approved version, the Creator loses permissions to view the item, and i get the "cannot find item" error from SharePoint for the person who created the item. The 1st and 2nd level approvers and anyone with approve rights CAN still see the item. Some more background information. the code i am using to update the moderationinformation is I get the properties from the workflow event and get a hook into the listitem properties.Item.ModerationInformation.Status = SPModerationStatusType.Pending; properties.Item.Update(); can anyone help.

    Read the article

  • How can I make a universal construction more efficient?

    - by VF1
    A "universal construction" is a wrapper class for a sequential object that enables it to be linearized (a strong consistency condition for concurrent objects). For instance, here's an adapted wait-free construction, in Java, from [1], which presumes the existence of a wait-free queue that satisfies the interface WFQ (which only requires one-time consensus between threads) and assumes a Sequential interface: public interface WFQ<T> // "FIFO" iteration { int enqueue(T t); // returns the sequence number of t Iterable<T> iterateUntil(int max); // iterates until sequence max } public interface Sequential { // Apply an invocation (method + arguments) // and get a response (return value + state) Response apply(Invocation i); } public interface Factory<T> { T generate(); } // generate new default object public interface Universal extends Sequential {} public class SlowUniversal implements Universal { Factory<? extends Sequential> generator; WFQ<Invocation> wfq = new WFQ<Invocation>(); Universal(Factory<? extends Sequential> g) { generator = g; } public Response apply(Invocation i) { int max = wfq.enqueue(i); Sequential s = generator.generate(); for(Invocation invoc : wfq.iterateUntil(max)) s.apply(invoc); return s.apply(i); } } This implementation isn't very satisfying, however, since it presumes determinism of a Sequential and is really slow. I attempted to add memory recycling: public interface WFQD<T> extends WFQ<T> { T dequeue(int n); } // dequeues only when n is the tail, else assists other threads public interface CopyableSequential extends Sequential { CopyableSequential copy(); } public class RecyclingUniversal implements Universal { WFQD<CopyableSequential> wfqd = new WFQD<CopyableSequential>(); Universal(CopyableSequential init) { wfqd.enqueue(init); } public Response apply(Invocation i) { int max = wfqd.enqueue(i); CopyableSequential cs = null; int ctr = max; for(CopyableSequential csq : wfq.iterateUntil(max)) if(--max == 0) cs = csq.copy(); wfqd.dequeue(max); return cs.apply(i); } } Here are my specific questions regarding the extension: Does my implementation create a linearizable multi-threaded version of a CopyableSequential? Is it possible extend memory recycling without extending the interface (perhaps my new methods trivialize the problem)? My implementation only reduces memory when a thread returns, so can this be strengthened? [1] provided an implementation for WFQ<T>, not WFQD<T> - one does exist, though, correct? [1] Herlihy and Shavit, The Art of Multiprocessor Programming.

    Read the article

  • Trying to fadein divs in a sequence, over time, using JQuery

    - by user346602
    Hi, I'm trying to figure out how to make 4 images fade in sequentially when the page loads. The following is my (amateurish) code: Here is the HTML: <div id="outercorners"> <img id="corner1" src="images/corner1.gif" width="6" height="6" alt=""/> <img id="corner2" src="images/corner2.gif" width="6" height="6" alt=""/> <img id="corner3" src="images/corner3.gif" width="6" height="6" alt=""/> <img id="corner4" src="images/corner4.gif" width="6" height="6" alt=""/> </div><!-- end #outercorners--> Here is the JQuery: $(document).ready(function() { $("#corner1").fadeIn("2000", function(){ $("#corner3").fadeIn("4000", function(){ $("#corner2").fadeIn("6000", function(){ $("#corner4").fadeIn("8000", function(){ }); }); }); }); Here is the css: #outercorners { position: fixed; top:186px; left:186px; width:558px; height:372px; } #corner1 { position: fixed; top:186px; left:186px; display: none; } #corner2 { position: fixed; top:186px; left:744px; display: none; } #corner3 { position: fixed; top:558px; left:744px; display: none; } #corner4 { position: fixed; top:558px; left:186px; display: none; } They seem to just wink at me, rather than fade in in the order I've ascribed to them. Should I be using the queue() function? And, if so, how would I implement it in this case? Thank you for any assistance.

    Read the article

  • sequencing function calls in javascript - are callbacks the only way?

    - by tim
    I read through various threads like this one for example. But it really escapes me how to accomplish the following: I have 4 functions, and want them happen one after another in sequence. Notice they are in incorrect order, to get my point across. I want the result that will output "1, 2, 3, 4' function firstFunction(){ // some very time consuming asynchronous code... console.log('1'); } function thirdFunction(){ // definitely dont wanna do this until secondFunction is finished console.log('3'); } function secondFunction(){ // waits for firstFunction to be completed console.log('2'); } function fourthFunction(){ // last function, not executed until the other 3 are done. console.log('4'); } I tried to figure out callbacks but am getting lost :( Isn't there some simple way to do this? Like looping through an array...

    Read the article

  • Benchmarking hosting providers IO with Bonnie

    - by Derek Organ
    Ok, because of a bunch of projects I'm working on I've access to dedicated Servers on a 3 hosting providers. As an experiment and for educational purposes I decided to see if I could benchmark how good the IO is with each. Bit of research lead me to Bonnie++ So I installed it on the server and ran this simple command /usr/sbin/bonnie -d /tmp/foo The 3 machines in different hosting providers are all dedicated machines, one is a VPS, other two are on some cloud platform e.g. VMWare / Xen using some kind of clustered SAN for storage This might be a naive thing to do but here are the results I found. HOST A Version 1.03c ------Sequential Output------ --Sequential Input- --Random- -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks-- Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP xxxxxxxxxxxxxxxx 1G 45081 88 56244 14 19167 4 20965 40 67110 6 67.2 0 ------Sequential Create------ --------Random Create-------- -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete-- files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP 16 15264 28 +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++ xxxxxxxx,1G,45081,88,56244,14,19167,4,20965,40,67110,6,67.2,0,16,15264,28,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++ HOST B Version 1.03d ------Sequential Output------ --Sequential Input- --Random- -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks-- Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP xxxxxxxxxxxx 4G 43070 91 64510 15 19092 0 29276 47 39169 0 448.2 0 ------Sequential Create------ --------Random Create-------- -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete-- files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP 16 24799 52 +++++ +++ +++++ +++ 25443 54 +++++ +++ +++++ +++ xxxxxxx,4G,43070,91,64510,15,19092,0,29276,47,39169,0,448.2,0,16,24799,52,+++++,+++,+++++,+++,25443,54,+++++,+++,+++++,+++ HOST C Version 1.03c ------Sequential Output------ --Sequential Input- --Random- -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks-- Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP xxxxxxxxxxxxx 1536M 15598 22 85698 13 258969 20 16194 22 723655 21 +++++ +++ ------Sequential Create------ --------Random Create-------- -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete-- files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP 16 14142 22 +++++ +++ 18621 22 13544 22 +++++ +++ 17363 21 xxxxxxxx,1536M,15598,22,85698,13,258969,20,16194,22,723655,21,+++++,+++,16,14142,22,+++++,+++,18621,22,13544,22,+++++,+++,17363,21 Ok, so first off what is the best way to read the figures and are there any issues with really comparing these numbers? Is this in any way a true representation of IO Speed? If not is there any way for me to test that? Note: these 3 machines are using either Ubuntu or Debian (I presume that doesn't really matter)

    Read the article

  • How do I create a reusable WF sequential workflow?

    - by djgiard
    I have two customers that have the same workflow (Create file -transport file - wait for response - send response to internal team); however the implementation of each step is different for each customer. For example, one customer requires a flat file to be sent via SFTP, while the other customer requires an XML file to be sent via FTP. I'd like to create a sequential workflow, using Microsoft Workflow Foundation (WF) and reuse this workflow for multiple vendors. Each action's call to an external module can use the same interface, but a different concrete implementation. However, I'm unfamiliar with WF and I'm not sure how to implement this. Can someone point me to the proper way to use this pattern? Will it make a difference whether I choose WF 3.5 or WF 4.0? Thank you.

    Read the article

  • Concurrent Programming:Should I write a sequential program first, then add thread safety?

    - by evthim
    I'm working on a project where we have to create a number of threads(actual number will be inputted in by testers (TA's)). I'm having trouble not only with the programming but also with the design, I can't wrap my head around all of the threads that will be invoked and where I might cause errors. The project is due soon so I don't want to waste time on this if it'll actually set me back, but I was wondering if I should write the program like only one thread will be running and everything should be sequential and then later go back and try to add the thread safety parts of the code? Would that take twice the original amount of time? Project Description: Note:I'm going to be as vague as possible so I don't violate any honor codes, sorry :( your program should accept n number of objectA threads, m number of objectB threads, and r number of objectC objectB threads interact with code in objectA. objectA threads interact with code in objectB and objectC objectB and objectC don't directly interact, but do so indirectly through objectA -ex: objectB needs something from objectA. objectA gets the result for that something by calling objectC my confusion stems mostly from the fact that all of this interactions will be done by m+n threads and there are various restrictions throughout the descriptions, like objectB can request something from objectA, and objectA has to wait for objectC to finish that something before returning it to objectB. Also each objectA thread can only work on one instruction from objectB at a time, etc. etc. I just want to know if I write the code so that there is only 1 objectA, 1 objectB and 1 object C, can I go back and easily modify it so that those 1's can be changed to m, n and r? Sorry again, if my description is a little bit confusing.

    Read the article

  • What naming pattern can I use for sequential file naming (photos) when only their relative sequence is known?

    - by Juhele
    I got some old scanned photos and I want to put them in correct order. Unfortunately, I have no possibility to find out the exact order, only relative one like: "hm, this photo was surely taken after this one" and organize them step-by-step by manually changing numbering again and again. Is there any program (best free or opensource), where could I interactively put the photo in correct order straightaway (maybe by changing the order by dragging with mouse) and finally apply some file renaming to keep the file order? thank you in advance PS: running Windows (XP and 7), but if you know something for linux, let me kno too, please

    Read the article

  • How can I combine sequential expression trees into a fast method?

    - by chillitom
    Suppose I have the following expressions: Expression<Action<T, StringBuilder>> expr1 = (t, sb) => sb.Append(t.Name); Expression<Action<T, StringBuilder>> expr2 = (t, sb) => sb.Append(", "); Expression<Action<T, StringBuilder>> expr3 = (t, sb) => sb.Append(t.Description); I'd like to be able to compile these into a method/delegate equivalent to the following: void Method(T t, StringBuilder sb) { sb.Append(t.Name); sb.Append(", "); sb.Append(t.Description); } What is the best way to approach this? I'd like it to perform well, ideally with performance equivalent to the above method.

    Read the article

  • Executing sequential stored procedures; works in query analyzer, doesn't in my .NET application

    - by evanmortland
    Hello, I have an audit record table that I am writing to. I am connecting to MyDb, which has a stored procedure called 'CreateAudit', which is a passthrough stored procedure to another database on the same machine called MyOther DB with a stored procedure called 'CreatedAudit' as well. In other words in MyDB I have CreateAudit, which does the following EXEC dbo.MyOtherDB.CreateAudit. I call the MyDb CreateAudit stored procedure from my application, using subsonic as the DAL. The first time I call it, I call it with the following (pseudocode): Result = CreateAudit(recordId, "Opened") One line after that, I call: Result2 = CreateAudit(recordId, "Closed") In my second stored procedure it is supposed to mark the record that was created by the CreateAudit(recordId, "Opened") with a status of closed. It works great if I run them independently of one another, but when they run in sequence in the application, the record is not marked as "Closed". When I run SQL profiler I see that both queries ran, and if I copy the queries out and run them from query analyzer the record gets marked as closed 100% of the time! When I run it from the application, about once every 20 times or so, the record is successfully marked closed - the other 19 times nothing happens, but I do not get an error! Is it possible for the .NET app to skip over the ouput from the first stored procedure and start executing the second stored procedure before the record in the first is created? When I add a "WAITFOR DELAY '00:00:00:003'" to the top of my stored procedure, the record is also closed 100% of the time. My head is spinning, any ideas why this is happening! Thanks for any responses, very interested in hearing how this can happen.

    Read the article

  • PHP Arrays: A good way to check if an array is associative or sequential?

    - by Wilco
    PHP treats all arrays as associative, so there aren't any built in functions. Can anyone recommend a fairly efficient way to check if an array contains only numeric keys? Basically, I want to be able to differentiate between this: $sequentialArray = array('apple', 'orange', 'tomato', 'carrot'); and this: $assocArray = array('fruit1' => 'apple', 'fruit2' => 'orange', 'veg1' => 'tomato', 'veg2' => 'carrot');

    Read the article

  • Model Binding to a List using non-sequential indexes. Can I access the index later?

    - by Kid A
    I'm following Phil's great tutorial on model binding to a list. I use input names like this: book[5804].title book[5804].author book[1234].title book[1234].author This works well and the data gets back to the model just fine, populating a list of books. What I'm looking for is a way to get access in the model to the index that was used to send the books. I'd like to get that number, "5804." This is because the index is of semantic importance. If I can access it, it saves me from setting another property on the object (book ID). Is there a way to see, either on the FormCollection or on the model after UpdateModel is called, what the index was when it was sent up?

    Read the article

  • Sequential numbering from recursive function? e.g. 2, 2.1, 2.1.1, 2.2, 2.2.1

    - by Pete
    I have a recursive function reading a "table of contents" of documents from a database. I would like to print numbering with the document that reflects where the item is in the tree, e.g. First item, 1.1 Child of first item, 1.1.1 Child of child of first item, 1.2 Child of first item, Second item, 2.1 Child of second item, etc. Rather stumped about this at the moment - help please?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >