Search Results

Search found 3659 results on 147 pages for 'sorted hash'.

Page 99/147 | < Previous Page | 95 96 97 98 99 100 101 102 103 104 105 106  | Next Page >

  • Sorting 1 million 8-digit numbers in 1MB of RAM

    - by Favourite Chigozie Onwuemene
    I have a computer with 1M of RAM and no other local storage. I must use it to accept 1 million 8-digit decimal numbers over a TCP connection, sort them, and then send the sorted list out over another TCP connection. The list of numbers may contain duplicates, which I must not discard. The code will be placed in ROM, so I need not subtract the size of my code from the 1M. I already have code to drive the ethernet port and handle TCP/IP connections, and it requires 2k for its state data, including a 1k buffer via which the code will read and write data. Is there a solution to this problem?

    Read the article

  • Cannot save Adobe Illustrations as .pdf files

    - by Parastar
    Hi, I use adobe Illustrator creative suite 3. Now there seems to be a problem. I can't save my Illustrations In the .pdf format, since this format seems to preserve the graphic quality this Is vitally Important to me. If I save the Graphic In .jpef /.gif or png there Is some serious loss of quality so I need to find out a way to get this sorted. when I try to save the graphic as pdf It says "An unknown error has occured" please can anyone help me out here? Thank you,

    Read the article

  • Using LEFT JOIN to only selection one joined row

    - by Alex
    I'm trying to LEFT JOIN two tables, to get a list of all rows from TABLE_1 and ONE related row from TABLE_2. I have tried LEFT JOIN and GROUP BY c_id, however I wan't the related row from TABLE_2 to be sorted by isHeadOffice DESC. Here are some sample tables TABLE 1 c_id Name ---------------- 1 USA 2 Canada 3 England 4 France 5 Spain TABLE2 o_id c_id Office isHeadOffice ------------------------------------------------ 1 1 New York 1 2 1 Washington 0 3 1 Boston 0 4 2 Toronto 0 5 3 London 0 6 3 Manchester 1 7 4 Paris 1 8 4 Lyon 0 So what I am trying to get from this would be something like: RESULTS c_id Name Office ---------------------------- 1 USA New York 2 Canada Toronto 3 England Manchester 4 France Paris 5 Spain NULL I'm using PHP & MySQL. Any ideas?

    Read the article

  • iPhone xcode array losing state after load

    - by Frames84
    Right i've had a search around and can't find anything. @synthesize list; // this is an NSArry -(void) viewDidLoad { NSArray *arr = [self getJSONFeed]; self.List = [arr retain]; // if i copy the access code into here it works fine. } -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger row = [indexPath row]; NSArray *vals = [list objectAtIndex:row] retain]; NSString *id = [vals valueForKey:@"id"]; // ERROR } right i've taken some of the code to try and provide it as simple as possible, ignore typo's and memory leaks this is sorted. Basically when I select a row I can't get data out of my 'list' array object. Please can anyone help me out?

    Read the article

  • Csharp: I am trying to get the top nth values from and rectangular array

    - by user355925
    I am reading a txt file for strings that represent intergers. the file is space delimited. I have created an array[10,2]. evertime the the strings 1~10 is found in the file I increment array[n,0] by 1. I also feed array[n,1] with numbers 1~10. ie txt file contents: 1/1/1 10/1/2001 1 1 10 2 2 3 1 5 10 word word 3 3 etc.. streamreader reads 1/1/1 and determines that is is not 1~10 streamreader reads 10/1/2001 and determines that it is not 1~10 streamreader reads 1 and ++array[0,0] streamreader reads 1 and ++array[0,0] streamreader reads 10 and ++array[9,0] etc.. the result will be: '1' was found 3 times '2' was found 2 times '3' was found 3 times '5' was found 1 time '10' was found 2 times My problem is that I need this array placed in order(sorted) by value of column 0 so that it would be: 1 3 2 10 5

    Read the article

  • design function: underlying structure to store list of results for print to file

    - by forest.peterson
    is this a good approach to print a list of items to csv file with a sublist attached to each item. The gist of the function is when an item is found that does not exactly macth then a list of close matches is generated - this works now writing out one list at a time to a command window. For export to a csv file I think all the lists must be generated, stored and then written at once. Right now I use a struct to store the attributes printed, each struct is an item on the list - these structs are then added to a sorted stack and when printed they pop off into write out. Is a stack of stacks of structs a good design?

    Read the article

  • Optimality of Binary Search

    - by templatetypedef
    Hello all- This may be a silly question, but does anyone know of a proof that binary search is asymptotically optimal? That is, if we are given a sorted list of elements where the only permitted operation on those objects is a comparison, how do you prove that the search can't be done in o(lg n)? (That's little-o of lg n, by the way.) Note that I'm restricting this to elements where the only operation permitted operation is a comparison, since there are well-known algorithms that can beat O(lg n) on expectation if you're allowed to do more complex operations on the data (see, for example, interpolation search). Thanks so much! This has really been bugging me since it seems like it should be simple but has managed to resist all my best efforts. :-)

    Read the article

  • difference between 2 pieces Python code

    - by draw
    Hello, I'm doing an exercise as following: # B. front_x # Given a list of strings, return a list with the strings # in sorted order, except group all the strings that begin with 'x' first. # e.g. ['mix', 'xyz', 'apple', 'xanadu', 'aardvark'] yields # ['xanadu', 'xyz', 'aardvark', 'apple', 'mix'] # Hint: this can be done by making 2 lists and sorting each of them # before combining them. sample solution: def front_x(words): listX = [] listO = [] for w in words: if w.startswith('x'): listX.append(w) else: listO.append(w) listX.sort() listO.sort() return listX + listO my solution: def front_x(words): listX = [] for w in words: if w.startswith('x'): listX.append(w) words.remove(w) listX.sort() words.sort() return listX + words as I tested my solution, the result is a little weird. Here is the source code with my solution: http://dl.dropbox.com/u/559353/list1.py. You might want to try it out.

    Read the article

  • Building a linked list with LINQ

    - by FreshCode
    What is the fastest way to order an unordered list of elements by predecessor (or parent) element index using LINQ? Each element has a unique ID and the ID of that element's predecessor (or parent) element, from which a linked list can be built to represent an ordered state. Example ID | Predecessor's ID --------|-------------------- 20 | 81 81 | NULL 65 | 12 12 | 20 120 | 65 The sorted order is {81, 20, 12, 65, 120}. An (ordered) linked list can easily be assembled iteratively from these elements, but can it be done in fewer LINQ statements? Edit: I should have specified that IDs are not necessarily sequential. I chose 1 to 5 for simplicity. See updated element indices which are random.

    Read the article

  • Oracle spatial search within distance

    - by KA_lin
    I have the following table Cities: ID(int),City(char),latitude(float),longitude(float). Now based on a user`s longitude(ex:44.8) and latitude(ex:46.3) I want to search for all the cities near him within 100 miles/KM. I have found some examples but don`t know how to adapt them to my case select * from GEO.Cities a where SDO_WITHIN_DISTANCE([I don`t know], MDSYS.SDO_GEOMETRY(2001, 8307, MDSYS.SDO_POINT_TYPE(44.8,46.3, NULL) ,NULL, NULL), 'distance = 1000') = 'TRUE'; Any help would be appreciated. P.S: If it is possible to have the distance and to be sorted P.P.S: I want to do it in this way due to performance issues, I have done this in this way http://www.scribd.com/doc/2569355/Geo-Distance-Search-with-MySQL but it takes too long...

    Read the article

  • Sorting Multidimensional Array with Javascript: Integers

    - by tkm256
    I have a 2D array called "results." Each "row" array in results contains both string and integer values. I'm using this script to sort the array by any "column" on an onclick event: function sort_array(results, column, direction) { var sorted_results = results.sort(value); function value(a,b) { a = a[column]; b = b[column]; return a == b ? 0 : (a < b ? -1*direction : 1*direction) } } This works fine for the columns with strings. But it treats the columns of integers like strings instead of numbers. For example, the values 15, 1000, 200, 97 would be sorted 1000, 15, 200, 97 if "ascending" or 97, 200, 15, 1000 "descending." I've double-checked the typeof the integer values, and the script knows they're numbers. How can I get it to treat them as such?

    Read the article

  • symlink files newer than X age, then later remove symlink once file ages?

    - by bleomycin
    Hello everyone, i have a large number of files/folders coming in each day that are being sorted automatically to a wide variety of folders. I'm looking for a way to automatically find these files/folders and create symlinks to them all within an "incoming" folder. Searching for file age should be sufficient for finding the files, however searching for age and owner would be ideal. Then once the files/folders being linked to reach a certain age, say 5 days, remove the symlinks to them automatically from the "incoming" folder. Is this possible to do with a simple shell or python script that can be run with cron? Thanks!

    Read the article

  • Convert Python 3.x snippet to C#/LINQ.

    - by Hamish Grubijan
    I want to sort elements of a HashSet<string> and join them by a ; character. Python interpreter version: >>> st = {'jhg', 'uywer', 'nbcm', 'utr'} >>> strng = ';'.join(sorted(s)) >>> strng 'ASD;anmbh;ashgg;jhghjg' C# signature of a method I seek: private string getVersionsSorted(HashSet<string> versions); I can do this without using Linq, but I really want to learn it better. Many thanks!

    Read the article

  • resort on a std::vector vs std::insert

    - by Abruzzo Forte e Gentile
    I have a sorted std::vector of relative small size ( from 5 to 20 elements ). I used std::vector since the data is continuous so I have speed because of cache. On a specific point I need to remove an element from this vector. I have now a doubt: which is the fastest way to remove this value between the 2 options below? setting that element to 0 and call sort to reorder: this has complexity but elements are on the same cache line. call erase that will copy ( or memcpy who knows?? ) all elements after it of 1 place ( I need to investigate the behind scense of erase ). Do you know which one is faster? I think that the same approach could be thought about inserting a new element without hitting the max capacity of the vector. Regards AFG

    Read the article

  • [FLEX 3] Placing images into a Collage Canvas

    - by Bridget
    I've got an array of different sized images. I want to place these images on a canvas in a sort of automated collage. Does anyone have an idea of how to work the logic behind this concept? All my images have heights divisible by 36 pixels and widths divisible by 9 pixels. They have mouseDown functions that allow you to drag and drop. When dropped the image goes to the closest x point divisible by 9 and y point divisble by 36. There is a grid drawn on top of the canvas. I've sorted the array of images based on height, then based on their widths. imagesArray.sortOn("height", Array.NUMERIC | Array.DESCENDING); imagesArray.sortOn("width", Array.NUMERIC | Array.DESCENDING); I'd like to take the largest image ( imageArray[0] ) to put in corner x,y = 0,0. Then randomize the rest of the images and fit them into the collage canvas.

    Read the article

  • Eclipse: The icons in "Display View" are all greyed out

    - by Mark Silberbauer
    The discussion here describes the "display view" in eclipse which allows one to to quickly evaluate java expressions. The thing is, when I open the display view the icons remain greyed out and I can't execute anything. The only icon that isn't is "clear console". The odd thing is, alot of the screenshots on the web show the same behaviour but the people posting about the feature don't mentioned it. There aren't any options in the context sensitive menu either. I'm trying it on a java project. I've tried it in the debug view and I get the same issue. I'll provide a screenshot once my hosting is sorted. I'm using eclipse 3.4.

    Read the article

  • Gridview SortExpression with 2 fields

    - by aron
    Hello, I have a GridView that get's its datasource from a complex object. So I'm doing the Sorting & Paging in the code behind. <asp:GridView ID="SystemsDetailList" runat="server" AllowSorting="true" AllowPaging="true" AutoGenerateColumns="False" ShowFooter="True" OnPageIndexChanging="gridView_PageIndexChanging" OnSorting="gridView_Sorting"> For an important title column I have a SortExpression with 2 fields: SortExpression="FunctionalAreaDisplayCode, EswbsDisplayCode" This in the code behind: protected void gridView_Sorting(object sender, GridViewSortEventArgs e) { BindSystemList(e.SortExpression, sortOrder); } public string sortOrder { get { if (ViewState["sortOrder"].ToString() == "desc") { ViewState["sortOrder"] = "asc"; } else { ViewState["sortOrder"] = "desc"; } return ViewState["sortOrder"].ToString(); } set { ViewState["sortOrder"] = value; } } For some reason it will keep "FunctionalAreaDisplayCode" always sorted ASC but the EswbsDisplayCode works fine as it flips between ASC and DESC correctly. and tips here? thanks!

    Read the article

  • compareTo() method java is acting weird

    - by Ron Paul
    hi im having trouble getting this to work im getting an error here with my object comparison...how could I cast the inches to a string ( i never used compare to with anything other than strings) , or use comparison operators to compare the intigers, Object comparison = this.inches.compareTo(obj.inches); here is my code so far import java.io.*; import java.util.*; import java.lang.Integer; import java.lang.reflect.Array; public class Distance implements Comparable<Distance> { private static final String HashCodeUtil = null; private int feet; private int inches; private final int DEFAULT_FT = 1; private final int DEFAULT_IN = 1; public Distance(){ feet = DEFAULT_FT; inches = DEFAULT_IN; } public Distance(int ft, int in){ feet = ft; inches = in; } public void setFeet(int ft){ try { if(ft<0){ throw new CustomException("Distance is not negative"); } } catch(CustomException c){ System.err.println(c); feet =ft; } } public int getFeet(){ return feet; } public void setInches(int in){ try { if (in<0) throw new CustomException("Distance is not negative"); //inches = in; } catch(CustomException c) { System.err.println(c); inches = in; } } public int getInches(){ return inches; } public String toString (){ return "<" + feet + ":" + inches + ">"; } public Distance add(Distance m){ Distance n = new Distance(); n.inches = this.inches + m.inches; n.feet = this.feet + m.feet; while(n.inches>12){ n.inches = n.inches - 12; n.feet++; } return n; } public Distance subtract(Distance f){ Distance m = new Distance(); m.inches = this.inches - f.inches; m.feet = this.feet - f.feet; while(m.inches<0){ m.inches = m.inches - 12; feet--; } return m; } @Override public int compareTo(Distance obj) { // TODO Auto-generated method stub final int BEFORE = -1; final int EQUAL = 0; final int AFTER = 1; if (this == obj) return EQUAL; if(this.DEFAULT_IN < obj.DEFAULT_FT) return BEFORE; if(this.DEFAULT_IN > obj.DEFAULT_FT) return AFTER; Object comparison = this.inches.compareTo(obj.inches); if (this.inches == obj.inches) return compareTo(null); assert this.equals(obj) : "compareTo inconsistent with equals"; return EQUAL; } @Override public boolean equals( Object obj){ if (obj != null) return false; if (!(obj intanceof Distance)) return false; Distance that = (Distance)obj; ( this.feet == that.feet && this.inches == that.inches); return true; else return false; } @Override public int hashCode(int, int) { int result = HashCodeUtil.inches; result = HashCodeUtil.hash(result, inches ); result = HashCodeUtil.hash(result, feet); ruturn result; }

    Read the article

  • [CakePHP] Pagination after inserting or updateing record

    - by user198003
    one more question related with cakephp... let's say that i have 20+ records in my table. they are sorted by some criteria, ie. by title. and on a list view, i have a list of 10 records, with available pagination. how can i achieve that when i insert new record, to be redirected to proper page, where i can see record that is just was insterted? how can i get information on which page i have to be redirected? hope my question is enough clear for understanding... tnx in adv!

    Read the article

  • How to remove an item from a structure array in C++?

    - by Antik
    I have the following array structure (linked list): struct str_pair { char ip [50] ; char uri [50] ; str_pair *next ; } ; str_pair *item; I know to create a new item, I need to use item = new str_pair; However, I need to be able to loop through the array and delete a particular item. I have the looping part sorted. But how do I delete an item from an array of structures?

    Read the article

  • Help doing a dynamic sort?

    - by Kevin
    I have a notifications table which contains different types of notifications for different events. Inside the table is a notifications_type:string column that contains the type of notification, i.e. "foo" or "bar" or "oof" I want the user to be able to select what notifications they want to display, so there are checkboxes below the result that correspond to prefs_display_foo:boolean, prefs_display_bar:boolean in the User model. What is an elegant way for me to set the :conditions in the find to properly display the sorted results? Also, currently I have it as a method in the user, but how would I do it as a has_many :notifications, :conditions = .....

    Read the article

  • Prevent initial array from sorting

    - by George
    I have an array where the order of the objects is important for when I finally output the array in a document. However, I'm also sorting the array in a function to find the highest value. The problem is that I after I run the function to find the highest value, I can't get the original sort order of the array back. // html document var data = [75,300,150,500,200]; createGraph(data); // js document function createGraph(data) { var maxRange = getDataRange(data); // simpleEncode() = google encoding function for graph var dataSet = simpleEncode(data,maxRange); } function getDataRange(dataArray) { var num = dataArray.sort(sortNumber); return num[0]; } I've also tried setting data to dataA and dataB and using dataB in the getDataRange function and dataA in the simpleEncode function. Either way, data always end up being sorted from highest to lowest.

    Read the article

  • How to optimize this script

    - by marks34
    I have written the following script. It opens a file, reads each line from it splitting by new line character and deleting first character in line. If line exists it's being added to array. Next each element of array is splitted by whitespace, sorted alphabetically and joined again. Every line is printed because script is fired from console and writes everything to file using standard output. I'd like to optimize this code to be more pythonic. Any ideas ? import sys def main(): filename = sys.argv[1] file = open(filename) arr = [] for line in file: line = line[1:].replace("\n", "") if line: arr.append(line) for line in arr: lines = line.split(" ") lines.sort(key=str.lower) line = ''.join(lines) print line if __name__ == '__main__': main()

    Read the article

  • Get the top nth values from a rectangular array

    - by user355925
    I am reading a txt file for strings that represent integers. The file is space delimited. I have created an array[10,2]. Everytime the strings 1~10 is found in the file I increment array[n,0] by 1. I also feed array[n,1] with numbers 1~10. i.e. txt file contents: 1/1/1 10/1/2001 1 1 10 2 2 3 1 5 10 word word 3 3 etc.. streamreader reads 1/1/1 and determines that is is not 1~10 streamreader reads 10/1/2001 and determines that it is not 1~10 streamreader reads 1 and ++array[0,0] streamreader reads 1 and ++array[0,0] streamreader reads 10 and ++array[9,0] etc.. The result will be: '1' was found 3 times '2' was found 2 times '3' was found 3 times '5' was found 1 time '10' was found 2 times My problem is that I need this array placed in order(sorted) by value of column 0 so that it would be: 1 3 2 10 5

    Read the article

  • Drupal 6: moving localhost to server | clear cached data

    - by artmania
    Hi friends, I worked on localhost to build my drupal site. then, I moved to server. Steps: Clear cache tables (Site Configuration Performance Clear Cached Data button) on localhost Export db and then import on live server Move files/folders to live server Edit settings.php to reflect live server config everything is working great until I make Clear Cached Data on Server. than my custom theme, custom front page, etc... all mess up :( What can be the problem? I appreciate helps so much!! Thanks! !!SORTED!! I used a subtheme for Zen, named mgf . then I had taken a back-up as mgf- somehow after I make Clear Cached Data, Drupal links to this mgf- which is old and doesnt have latest stylings. I just removed this folder from themes, and it linked to the right-latest mgf.

    Read the article

< Previous Page | 95 96 97 98 99 100 101 102 103 104 105 106  | Next Page >