Search Results

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

Page 118/147 | < Previous Page | 114 115 116 117 118 119 120 121 122 123 124 125  | Next Page >

  • Design patter to keep track UITableView rows correspondance to underlying data in constant time.

    - by DenNukem
    When my model changes I want to animate changes in UITableView by inserting/deleting rows. For that I need to know the ordinal of the given row (so I can construct NSIndexPath), which I find hard to do in better-than-linear time. For example, consider that I have a list of addressbook entries which are manualy sorted by the user, i.e. there is no ordering "key" that represents the sort order. There is also a corresponding UITableView that shows one row per addressbook entry. When UITableView queries the datasource I query the NSMUtableArray populated with my entries and return required data in constant time for each row. However, if there is a change in underlying model I am getting a notification "Joe Smith, id#123 has been removed". Now I have a dilemma. A naive approach would be to scan the array, determine the index at which Joe Smith is and then ask UITableView to remove that precise row from the view, also removing it form the array. However, the scan will take linear time to finish. Now I could have an NSDictionary which allows me to find Joe Smith in constant time, but that doesn't do me a lot of good because I still need to find his ordinal index within the array in order to instruct UITableView to remove that row, which is again a linear search. I could further decide to store each object's ordinal inside the object itself to make it constant, but it will become outdated after first such update as all subsequent index values will have changed due to removal of an object. So what is the correct design pattern to accurately reflect model changes in the UITableView in costant (or at least logarithmic) time?

    Read the article

  • Forcing an item to remain in place in a jQuery UI Sortable list

    - by calumbrodie
    I've set up a jQuery sortable list but I need to be able to keep some items in the sortable 'fixed' in place and for the other items to sort around them. I thought that there would be built in methods to achieve this, alas this is not the case. I'm able to set up the list and not include the items in question: <ul id="fruit"> <li class="fixed">apples</li> <li>oranges</li> <li>bananas</li> <li>pineapples</li> <li>grapes</li> <li class="fixed">pears</li> <li>mango</li> </ul> <script type="text/javascript"> $('#fruit').sortable({items: "li:not('.fixed')"}) </script> This stops me from drag/dropping these items but they still move if the items around them are sorted. There may be a way to do this using the many callbacks that this method has but I've been unable to work this out. Maybe this method would be a good addition to the UI Sortable options?

    Read the article

  • (1 2 3 . #<void>)- heapsort

    - by superguay
    Hello everybody: I tried to implement a "pairing heap" with all the regular operations (merge, delete-min etc.), then I've been requested to write a function that would sort a list using my newly constructed heap implementation. Unfortunately it seems that someting goes wrong... Here's the relevant code: (define (heap-merge h1 h2) (cond ((heap-empty? h1) h2) ((heap-empty? h2) h1) (else (let ((min1 (heap-get-min h1)) (min2 (heap-get-min h2))) (if ((heap-get-less h1) min1 min2) (make-pairing-heap (heap-get-less h1) min1 (cons h2 (heap-get-subheaps h1))) (make-pairing-heap (heap-get-less h1) min2 (cons h1 (heap-get-subheaps h2)))))))) (define (heap-insert element h) (heap-merge (make-pairing-heap (heap-get-less h) element '()) h)) (define (heap-delete-min h) (define (merge-in-pairs less? subheaps) (cond ((null? subheaps) (make-heap less?)) ((null? (cdr subheaps)) (car subheaps)) (else (heap-merge (heap-merge (car subheaps) (cadr subheaps)) (merge-in-pairs less? (cddr subheaps)))))) (if (heap-empty? h) (error "expected pairing-heap for first argument, got an empty heap ") (merge-in-pairs (heap-get-less h) (heap-get-subheaps h)))) (define (heapsort l less?) (let aux ((h (accumulate heap-insert (make-heap less?) l))) (if (not (heap-empty? h)) (cons (heap-get-min h) (aux (heap-delete-min h)))))) And these are some selectors that may help you to understand the code: (define (make-pairing-heap less? min subheaps) (cons less? (cons min subheaps))) (define (make-heap less?) (cons less? '())) (define (heap-get-less h) (car h)) (define (heap-empty? h) (if (null? (cdr h)) #t #f)) Now lets get to the problem: When i run 'heapsort' it returns the sorted list with "void", as you can see: (heapsort (list 1 2 3) <) (1 2 3 . #)..HOW CAN I FIX IT? Regards, Superguay

    Read the article

  • How to sort linq result by most similarity/equality

    - by aNui
    I want to do a search for Music instruments which has its informations Name, Category and Origin as I asked in my post. But now I want to sort/group the result by similarity/equality to the keyword such as. If I have the list { Drum, Grand Piano, Guitar, Guitarrón, Harp, Piano} << sorted by name and if I queried "p" the result should be { Piano, Grand Piano, Harp } but it shows Harp first because of the source list's sequence and if I add {Grand Piano} to the list and query "piano" the result shoud be like { Piano, Grand Piano } or query "guitar" it should be { Guitar, Guitarrón } here's my code static IEnumerable<MInstrument> InstrumentsSearch(IEnumerable<MInstrument> InstrumentsList, string query, MInstrument.Category[] SelectedCategories, MInstrument.Origin[] SelectedOrigins) { var result = InstrumentsList .Where(item => SelectedCategories.Contains(item.category)) .Where(item => SelectedOrigins.Contains(item.origin)) .Where(item => { if ( (" " + item.Name.ToLower()).Contains(" " + query.ToLower()) || item.Name.IndexOf(query) != -1 ) { return true; } return false; } ) .Take(30); return result.ToList<MInstrument>(); } Or the result may be like my old self-invented algorithm that I called "by order of occurence", that is just OK to me. And the further things to do is I need to search the Name, Category or Origin such as. If i type "Italy" it should found Piano or something from Italy. Or if I type "string" it should found Guitar. Is there any way to do those things, please tell me. Thanks in advance.

    Read the article

  • Compression algorithm for IEEE-754 data

    - by David Taylor
    Anyone have a recommendation on a good compression algorithm that works well with double precision floating point values? We have found that the binary representation of floating point values results in very poor compression rates with common compression programs (e.g. Zip, RAR, 7-Zip etc). The data we need to compress is a one dimensional array of 8-byte values sorted in monotonically increasing order. The values represent temperatures in Kelvin with a span typically under of 100 degrees. The number of values ranges from a few hundred to at most 64K. Clarifications All values in the array are distinct, though repetition does exist at the byte level due to the way floating point values are represented. A lossless algorithm is desired since this is scientific data. Conversion to a fixed point representation with sufficient precision (~5 decimals) might be acceptable provided there is a significant improvement in storage efficiency. Update Found an interesting article on this subject. Not sure how applicable the approach is to my requirements. http://users.ices.utexas.edu/~burtscher/papers/dcc06.pdf

    Read the article

  • Problem sorting RSS feed by date using XSL

    - by Buckers
    I'm creating a website where I need to show the top 5 records from an RSS feed, and these need to be sorted by date and time. The date fields in the RSS feed are in the following format: "Mon, 16 Feb 2009 16:02:44 GMT" I'm having big problems getting the records to sort correctly - I've tried lots of different code examples I've seen, but none seem to sort the records correctly. The code for my XSL sheet is shown below, and the feed in question is here. Very grateful for anyones help!!! Thanks, Chris. XSL CODE: <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:digg="http://digg.com//docs/diggrss/" xmlns:dc="http://purl.org/dc/elements/1.1/"> <xsl:template match="/"> <xsl:for-each select="//*[local-name()='item'][position() < 6]"> <p> <a> <xsl:attribute name="href"> <xsl:value-of select="*[local-name()='link']"/></xsl:attribute> <xsl:attribute name="target"> <xsl:text>top</xsl:text> </xsl:attribute> <xsl:value-of select="*[local-name()='title']"/> </a> <br/> <span class="smaller"><xsl:value-of select="*[local-name()='pubDate']" disable-output-escaping="yes"/></span> </p> </xsl:for-each>

    Read the article

  • Sorting arrays with cyclic compares (infinite loop?)

    - by Tiago
    Hi, I have some objects that have 3 sorting options: quality, quatity and a compare against the other object, sorted by that order. - (NSComparisonResult) compare: (MyObject *) obj { if (self.quality > obj.quality) return NSOrderedAscending; else if (self.quality < obj.quality) return NSOrderedDescending; if (self.quantity > obj.quantity) return NSOrderedAscending; else if (self.quantity < obj.quantity) return NSOrderedDescending; if ([self betterThan: obj]) return NSOrderedAscending; if ([obj betterThan: self]) return NSOrderedDescending; return NSOrderedSame; } My problem is that, the betterThan: method might cause a cyclic compare if the objects have the same quality and quantity, and I want to return any sort order in that case. For example, A, B and C have the same quality/quantity, but A betterThan: B => YES B betterThan: C => YES C betterThan: A => YES Solutions? Thanks.

    Read the article

  • Array of paths to html lists

    - by dmsk
    I wrote a recursive function, which returns an array with the paths to all files/folders in a given path. An array is already sorted and returns the exact information i want, but i struggle to display it properly in html lists. Array_of_paths = ( [0] => /path/to/folderA/ [1] => /path/to/folderA/subfolderAA/ [2] => /path/to/folderB/ [3] => /path/to/folderB/subfolderBB/ [4] => /path/to/folderB/subfolderBB/fileBB.txt [5] => /path/to/folderB/fileB.txt [6] => /path/to/folderC/ ... ) I want to put these paths in <ul>,<li> tags to see something like this: <ul> <li>/path/to/folderA/ <ul> <li>/path/to/folderA/folderAA/</li> </ul> </li> <li>/path/to/folderB <ul> <li>/path/to/folderB/subfolderBB/ <ul> <li>/path/to/folderB/subfolderBB/fileBB.txt</li> </ul> </li> <li>/path/to/folderB/fileB.txt</li> </ul> </li> <li>/path/to/folderC/</li> </ul> = /path/to/folderA/ /path/to/folderA/folderAA/ /path/to/folderB /path/to/folderB/subfolderBB/ /path/to/folderB/subfolderBB/fileBB.txt /path/to/folderB/fileB.txt /path/to/folderC/ I managed to find a couple of similars questions, but the answers were in Ruby language. So, what's the problem solving idea behind this?

    Read the article

  • Python sorting list of dictionaries by multiple keys

    - by simi
    I have a list of dicts: b = [{u'TOT_PTS_Misc': u'Utley, Alex', u'Total_Points': 96.0}, {u'TOT_PTS_Misc': u'Russo, Brandon', u'Total_Points': 96.0}, {u'TOT_PTS_Misc': u'Chappell, Justin', u'Total_Points': 96.0}, {u'TOT_PTS_Misc': u'Foster, Toney', u'Total_Points': 80.0}, {u'TOT_PTS_Misc': u'Lawson, Roman', u'Total_Points': 80.0}, {u'TOT_PTS_Misc': u'Lempke, Sam', u'Total_Points': 80.0}, {u'TOT_PTS_Misc': u'Gnezda, Alex', u'Total_Points': 78.0}, {u'TOT_PTS_Misc': u'Kirks, Damien', u'Total_Points': 78.0}, {u'TOT_PTS_Misc': u'Worden, Tom', u'Total_Points': 78.0}, {u'TOT_PTS_Misc': u'Korecz, Mike', u'Total_Points': 78.0}, {u'TOT_PTS_Misc': u'Swartz, Brian', u'Total_Points': 66.0}, {u'TOT_PTS_Misc': u'Burgess, Randy', u'Total_Points': 66.0}, {u'TOT_PTS_Misc': u'Smugala, Ryan', u'Total_Points': 66.0}, {u'TOT_PTS_Misc': u'Harmon, Gary', u'Total_Points': 66.0}, {u'TOT_PTS_Misc': u'Blasinsky, Scott', u'Total_Points': 60.0}, {u'TOT_PTS_Misc': u'Carter III, Laymon', u'Total_Points': 60.0}, {u'TOT_PTS_Misc': u'Coleman, Johnathan', u'Total_Points': 60.0}, {u'TOT_PTS_Misc': u'Venditti, Nick', u'Total_Points': 60.0}, {u'TOT_PTS_Misc': u'Blackwell, Devon', u'Total_Points': 60.0}, {u'TOT_PTS_Misc': u'Kovach, Alex', u'Total_Points': 60.0}, {u'TOT_PTS_Misc': u'Bolden, Antonio', u'Total_Points': 60.0}, {u'TOT_PTS_Misc': u'Smith, Ryan', u'Total_Points': 60.0}] and I need to use a multi key sort reversed by Total_Points, then not reversed by TOT_PTS_Misc. This can be done at the command prompt like so: a = sorted(b, key=lambda d: (-d['Total_Points'], d['TOT_PTS_Misc'])) But I have to run this through a function, where I pass in the list and the sort keys. For example, def multikeysort(dict_list, sortkeys):. How can the lambda line be used which will sort the list, for an arbitrary number of keys that are passed in to the multikeysort function, and take into consideration that the sortkeys may have any number of keys and those that need reversed sorts will be identified with a '-' before it?

    Read the article

  • DATE lookup table (1990/01/01:2041/12/31)

    - by Frank Developer
    I use a DATE's master table for looking up dates and other values in order to control several events, intervals and calculations within my app. It has rows for every single day begining from 01/01/1990 to 12/31/2041. One example of how I use this lookup table is: A customer pawned an item on: JAN-31-2010 Customer returns on MAY-03-2010 to make an interest pymt to avoid forfeiting the item. If he pays 1 months interest, the employee enters a "1" and the app looks-up the pawn date (JAN-31-2010) in date master table and puts FEB-28-2010 in the applicable interest pymt date. FEB-28 is returned because FEB-31's dont exist! If 2010 were a leap-year, it would've returned FEB-29. If customer pays 2 months, MAR-31-2010 is returned. 3 months, APR-30... If customer pays more than 3 months or another period not covered by the date lookup table, employee manually enters the applicable date. Here's what the date lookup table looks like: { Copyright 1990:2010, Frank Computer, Inc. } { DBDATE=YMD4- (correctly sorted for faster lookup) } CREATE TABLE datemast ( dm_lookup DATE, {lookup col used for obtaining values below} dm_workday CHAR(2), {NULL=Normal Working Date,} {NW=National Holiday(Working Date),} {NN=National Holiday(Non-Working Date),} {NH=National Holiday(Half-Day Working Date),} {CN=Company Proclamated(Non-Working Date),} {CH=Company Proclamated(Half-Day Working Date)} {several other columns omitted} dm_description CHAR(30), {NULL, holiday description or any comments} dm_day_num SMALLINT, {number of elapsed days since begining of year} dm_days_left SMALLINT, (number of remaining days until end of year} dm_plus1_mth DATE, {plus 1 month from lookup date} dm_plus2_mth DATE, {plus 2 months from lookup date} dm_plus3_mth DATE, {plus 3 months from lookup date} dm_fy_begins DATE, {fiscal year begins on for lookup date} dm_fy_ends DATE, {fiscal year ends on for lookup date} dm_qtr_begins DATE, {quarter begins on for lookup date} dm_qtr_ends DATE, {quarter ends on for lookup date} dm_mth_begins DATE, {month begins on for lookup date} dm_mth_ends DATE, {month ends on for lookup date} dm_wk_begins DATE, {week begins on for lookup date} dm_wk_ends DATE, {week ends on for lookup date} {several other columns omitted} ) IN "S:\PAWNSHOP.DBS\DATEMAST"; Is there a better way of doing this or is it a cool method?

    Read the article

  • Binary Search Tree in Java

    - by John R
    I want to make a generic BST, that can be made up of any data type, but i'm not sure how I could add things to the tree, if my BST is generic. All of my needed code is below. I want my BST made up of Locations, and sorted by the x variable. Any help is appreciated. Major thanks for looking. public void add(E element) { if (root == null) root = element; if (element < root) add(element, root.leftChild); if (element > root) add(element, root.rightChild); else System.out.println("Element Already Exists"); } private void add(E element, E currLoc) { if (currLoc == null) currLoc = element; if (element < root) add(element, currLoc.leftChild); if (element > root) add(element, currLoc.rightChild); else System.out.println("Element Already Exists); } Other Code public class BinaryNode<E> { E BinaryNode; BinaryNode nextBinaryNode; BinaryNode prevBinaryNode; public BinaryNode() { BinaryNode = null; nextBinaryNode = null; prevBinaryNode = null; } } public class Location<AnyType> extends BinaryNode { String name; int x,y; public Location() { name = null; x = 0; y = 0; } public Location(String newName, int xCord, int yCord) { name = newName; x = xCord; y = yCord; } public int equals(Location otherScene) { return name.compareToIgnoreCase(otherScene.name); } }

    Read the article

  • Composite key syntax in Boost MultiIndex

    - by Sarah
    Even after studying the examples, I'm having trouble figuring out how to extract ranges using a composite key on a MultiIndex container. typedef multi_index_container< boost::shared_ptr< Host >, indexed_by< hashed_unique< const_mem_fun<Host,int,&Host::getID> >, // ID index ordered_non_unique< const_mem_fun<Host,int,&Host::getAgeInY> >, // Age index ordered_non_unique< const_mem_fun<Host,int,&Host::getHousehold> >, // Household index ordered_non_unique< // Age & eligibility status index composite_key< Host, const_mem_fun<Host,int,&Host::getAgeInY>, const_mem_fun<Host,bool,&Host::isPaired> > > > // end indexed_by > HostContainer; My goal is to get an iterator pointing to the first of the subset of elements in HostContainer hmap that has age partnerAge and returns false to Host::isPaired(): std::pair< hmap::iterator,hmap::iterator > pit = hmap.equal_range(boost::make_tuple( partnerAge, false ) ); I think this is very wrong. How/Where do I specify the iterator index (which should be 3 for age & eligibility)? I will include other composite keys in the future. What exactly are the two iterators in std::pair? (I'm copying syntax from an example that I don't understand.) I would ideally use std::count to calculate the number of elements of age partnerAge that are eligible (return false to Host::isPaired()). What is the syntax for extracting the sorted index that meets these requirements? I'm obviously still learning C++ syntax. Thanks in advance for any help.

    Read the article

  • Generating all unique combinations for "drive ya nuts" puzzle

    - by Yuval A
    A while back I wrote a simple python program to brute-force the single solution for the drive ya nuts puzzle. The puzzle consists of 7 hexagons with the numbers 1-6 on them, and all pieces must be aligned so that each number is adjacent to the same number on the next piece. The puzzle has ~1.4G non-unique possibilities: you have 7! options to sort the pieces by order (for example, center=0, top=1, continuing in clockwise order...). After you sorted the pieces, you can rotate each piece in 6 ways (each piece is a hexagon), so you get 6**7 possible rotations for a given permutation of the 7 pieces. Totalling: 7!*(6**7)=~1.4G possibilities. The following python code generates these possible solutions: def rotations(p): for i in range(len(p)): yield p[i:] + p[:i] def permutations(l): if len(l)<=1: yield l else: for perm in permutations(l[1:]): for i in range(len(perm)+1): yield perm[:i] + l[0:1] + perm[i:] def constructs(l): for p in permutations(l): for c in product(*(rotations(x) for x in p)): yield c However, note that the puzzle has only ~0.2G unique possible solutions, as you must divide the total number of possibilities by 6 since each possible solution is equivalent to 5 other solutions (simply rotate the entire puzzle by 1/6 a turn). Is there a better way to generate only the unique possibilities for this puzzle?

    Read the article

  • Getting duplicate key values in array

    - by WmasterJ
    For some reason when trying to populate an array I am not getting the desired result. In the first part I create an array of arrays, the key of each has a name such as "Biology Education". But when I then populate that same array it doesn't for some reason use the same array element but a new one. So part 1 results in an array with 13 array elements (empty). After part 2 has run the array has 26 array elements, with the first 13 empty and the other 13 populated as wanted. The reason why I want to work is that the first 13 array elements are sorted. The last 13 are jumbled. Why is this happening and how can I correct it? // PART 1 // Create array of research areas $research_result = db_fetch_array($research['research_query_result']); $research['areas'] = explode("\n", $research_result['options']); // Put the values as key and every key the new value of an array object $research['areas'] = array_fill_keys($research['areas'], array()); // PART 2 foreach($research['user'] as $uid => &$user_object) { $user_object->profile_research_areas = explode(", ", $user_object->profile_research_areas); foreach($user_object->profile_research_areas as $key => $area) { $research['areas'][$area][] = $uid; } }

    Read the article

  • iPhone contacts app styled indexed table view implementation

    - by KSH
    My Requirement: I have this straight forward requirement of listing names of people in alphabetical order in a Indexed table view with index titles being the starting letter of alphabets (additionally a search icon at the top and # to display misc values which start with a number and other special characters). What I have done so far: 1. I am using core data for storage and "last_name" is modelled as a String property in the Contacts entity 2.I am using a NSFetchedResultsController to display the sorted indexed table view. Issues accomplishing my requirement: 1. First up, I couldn't get the section index titles to be the first letter of alphabets. Dave's suggestion in the following post, helped me achieve the same: http://stackoverflow.com/questions/1112521/nsfetchedresultscontroller-with-sections-created-by-first-letter-of-a-string The only issue I encountered with Dave' suggestion is that I couldn't get the misc named grouped under "#" index. What I have tried: 1. I tried adding a custom compare method to NSString (category) to check how the comparison and section is made but that custom method doesn't get called when specified in the NSSortDescriptor selector. Here is some code: `@interface NSString (SortString) -(NSComparisonResult) customCompare: (NSString*) aStirng; @end @implementation NSString (SortString) -(NSComparisonResult) customCompare:(NSString *)aString { NSLog(@"Custom compare called to compare : %@ and %@",self,aString); return [self caseInsensitiveCompare:aString]; } @end` Code to fetch data: `NSArray *sortDescriptors = [NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"last_name" ascending:YES selector:@selector(customCompare:)] autorelease]]; [fetchRequest setSortDescriptors:sortDescriptors]; fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:@"lastNameInitial" cacheName:@"MyCache"];` Can you let me know what I am missing and how the requirement can be accomplished ?

    Read the article

  • Numeric Order By In Transact SQL (Ordering As String Instead Of Int)

    - by Pyronaut
    I have an issue where I am trying to order a result set by what I believe to be a numberic column in my database. However when I get the result set, It has sorted the column as if it was a string (So alphabetically), instead of sorting it as an int. As an example. I have these numbers, 1 , 2, 3, 4, 5, 10, 11 When I order by in Transact SQL, I get back : 1, 10, 11, 2, 3, 4, 5 I had the same issue with Datagridview's a while back, And the issue was because of the sorting being done as if it was a string. I assume the same thing is happening here. My full SQL code is : SELECT TOP (12) DATEPART(YEAR, [OrderDate]) AS 'Year', DATEPART(MONTH, [OrderDate]) AS 'Month' , COUNT(OrderRef) AS 'OrderCount' FROM [Order] WHERE [Status] LIKE('PaymentReceived') OR [Status] LIKE ('Shipped') GROUP BY DATEPART(MONTH, [OrderDate]), DATEPART(YEAR, [OrderDate]) ORDER BY DATEPART(YEAR, OrderDate) DESC, DATEPART(MONTH, OrderDate) desc DO NOTE The wrong sorting only happens when I cam calling the function from Visual Studio. As in my code is : using (SqlConnection conn = GetConnection()) { string query = @"SELECT TOP (12) DATEPART(YEAR, [OrderDate]) AS 'Year', DATEPART(MONTH, [OrderDate]) AS 'Month' , COUNT(OrderRef) AS 'OrderCount' FROM [Order] WHERE [Status] LIKE('PaymentReceived') OR [Status] LIKE ('Shipped') GROUP BY DATEPART(MONTH, [OrderDate]), DATEPART(YEAR, [OrderDate]) ORDER BY DATEPART(YEAR, OrderDate) DESC, DATEPART(MONTH, OrderDate) desc"; SqlCommand command = new SqlCommand(query, conn); command.CommandType = CommandType.Text; using (SqlDataReader reader = command.ExecuteReader()) etc. When I run the statement in MSSQL server, there is no issues. I am currently using MSSQL 2005 express edition, And Visual Studio 2005. I have tried numerous things that are strewn across the web. Including using Convert() and ABS() to no avail. Any help would be much appreciated.

    Read the article

  • how to fix: ctags null expansion of name pattern "\1"

    - by bua
    Hi, As the title points I have problem with ctags when trying to parse user-defined language. Basically I've followed those instructions. The quickest and easiest way to do this is by defining a new language using the program options. In order to have Swine support available every time I start ctags, I will place the following lines into the file $HOME/.ctags, which is read in every time ctags starts: --langdef=swine --langmap=swine:.swn --regex-swine=/^def[ \t]*([a-zA-Z0-9_]+)/\1/d,definition/ The first line defines the new language, the second maps a file extension to it, and the third defines a regular expression to identify a language definition and generate a tag file entry for it. I've tried different flags: b,e for regex. My definition of tag is: --regex-q=/^[ \t]*[^[:space:]]*[:space:]*:[:space:]*{/\l/f,function/b When I replace \1 with anything else (ascii caracter set ), It works. the output is: (--regex-q=/^[ \t]*[^[:space:]]*[:space:]*:[:space:]*{/my function name/f,function/b) !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ !_TAG_PROGRAM_AUTHOR Darren Hiebert /[email protected]/ !_TAG_PROGRAM_NAME Exuberant Ctags // !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ !_TAG_PROGRAM_VERSION 5.8 // my function name file.q /^.ras.getLocation:{[u]$/;" f my function name file.q /^.a.getResource:{[u; pass]$/;" f my function name file.q /^.a.init:{$/;" f my function name file.q /^.a.kill:{[u; force]$/;" f my function name file.q /^.asdf.status:{[what; u]$/;" f my function name file.q /^.pc:{$/;" f Why \1 doesn't work? (I've tried all 1-9)

    Read the article

  • GAE python database object design for simple list of values

    - by Joey
    I'm really new to database object design so please forgive any weirdness in my question. Basically, I am use Google AppEngine (Python) and contructing an object to track user info. One of these pieces of data is 40 Achievement scores. Do I make a list of ints in the User object for this? Or do I make a separate entity with my user id, the achievement index (0-39) and the score and then do a query to grab these 40 items every time I want to get the user data in total? The latter approach seems more object oriented to me, and certainly better if I extend it to have more than just scores for these 40 achievements. However, considering that I might not extend it, should I even consider just doing a simple list of 40 ints in my user data? I would then forgo doing a query, getting the sorted list of achievements, reading the score from each one just to process a response etc. Is doing this latter approach just such a common practice and hand-waved as not even worth batting an eyelash at in terms of thinking it might be more costly or complex processing wise?

    Read the article

  • How to keep only duplicates efficiently?

    - by Marc Eaddy
    Given an STL vector, I'd like an algorithm that outputs only the duplicates in sorted order, e.g., INPUT : { 4, 4, 1, 2, 3, 2, 3 } OUTPUT: { 2, 3, 4 } The algorithm is trivial, but the goal is to make it as efficient as std::unique(). My naive implementation modifies the container in-place: My naive implementation: void keep_duplicates(vector<int>* pv) { // Sort (in-place) so we can find duplicates in linear time sort(pv->begin(), pv->end()); vector<int>::iterator it_start = pv->begin(); while (it_start != pv->end()) { size_t nKeep = 0; // Find the next different element vector<int>::iterator it_stop = it_start + 1; while (it_stop != pv->end() && *it_start == *it_stop) { nKeep = 1; // This gets set redundantly ++it_stop; } // If the element is a duplicate, keep only the first one (nKeep=1). // Otherwise, the element is not duplicated so erase it (nKeep=0). it_start = pv->erase(it_start + nKeep, it_stop); } } If you can make this more efficient, elegant, or general, please let me know. For example, a custom sorting algorithm, or copy elements in the 2nd loop to eliminate the erase() call.

    Read the article

  • SQLDeveloper using over 100MB of PGA

    - by Leigh Riffel
    Perhaps this is normal, but in my Oracle 11g database I am seeing programmers using Oracle's SQL Developer regularly consume more than 100MB of combined UGA and PGA memory. I'd like to know if this is normal and what can be done about it. Our database is on the 32 bit version of Windows 2008, so memory limitations are becoming an increasing concern. I am using the following query to show the memory usage: SELECT e.SID, e.username, e.status, b.PGA_MEMORY FROM v$session e LEFT JOIN (select y.SID, y.value pga, TO_CHAR(ROUND(y.value/1024/1024),99999999) || ' MB' PGA_MEMORY from v$sesstat y, v$statname z where y.STATISTIC# = z.STATISTIC# and NAME = 'session pga memory') b ON e.sid=b.sid WHERE (PGA)/1024/1024 > 20 ORDER BY 4 DESC; It seems that the resource usage goes up any time a table is opened in SQLDeveloper, but even when it is closed the memory does not go away. The problem is worse if the table is sorted while it was open as that seems to use even more memory. I understand how this would use memory while it is sorting, and perhaps even while it is still open, but to use memory after it is closed seems wrong to me. Can anyone confirm this? Update: I discovered that my numbers were off due to not understanding that the UGA is stored in the PGA under dedicated server mode. This makes the numbers lower than they were, but the problem still remains that SQL Developer seems to use excessive PGA.

    Read the article

  • How to sort a list so that managers are always ahead of their subordinates

    - by James Black
    I am working on a project using Groovy, and I would like to take an array of employees, so that no manager follows their subordinates in the array. The reason being that I need to add people to a database and I would prefer not to do it in two passes. So, I basically have: <employees> <employee> <employeeid>12</employeeid> <manager>3</manager> </employee> <employee> <employeeid>1</employeeid> <manager></manager> </employee> <employee> <employeeid>3</employeeid> <manager>1</manager> </employee> </employees> So, it should be sorted as such: employeeid = 1 employeeid = 3 employeeid = 12 The first person should have a null for managers. I am thinking about a binary tree representation, but I expect it will be very unbalanced, and I am not certain the best way to do this using Groovy properly. Is there a way to do this that isn't going to involve using nested loops?

    Read the article

  • How to get NSFormatter subclass to work with NSTableColumn sort key and selector?

    - by Andrew
    My setup: I have a sqlite database from which I populate a NSMutableArray of NSDictionary objects this is the DataSource for my NSTableView. One of the columns holds "time", the time is a float that holds seconds. I would like to display the values in this column as minutes:seconds. For instance my data would be 123.4329387 I want to display 2:03 which I have no problem doing with a subclass of NSFormatter (or NSNumberFormatter) applied to my NSTextField in the column. I have sorting set up by using the Table Column Attributes in IB, I just have the sort key set to "time" and the selector set to "compare:" which works fine without the formatter. Currently this gives me something like this when I sort (descending) 1:37, 1:31, 0:10, 0:10, 0:09, 1:30, 1:30, 1:26, 0:09 and similar nonsense, it looks like something is going on but it's definitely not sorted. How do I get the sort to look at the underlying data instead of the formatted value? Alternately, how do I specify a custom sort method and where do I put the code for said method? I have searched around quite a bit and have not found anything to help me out with this problem, any help with this is most appreciated.

    Read the article

  • Alternative Python standard library reference

    - by Ender
    I love Python; I absolutely despise its official documentation. Tutorials do not count as library references, but that appears to be what they're attempting. What I really want is the ability to find a class in the standard library and view documentation for all of its properties and methods. Actionscript, MSDN, and Java all do this just fine (although each with their odd quirks). Where is this for python? For example, I wanted to sort a list. mylist.sort(). Awesome. But what if I wanted it sorted in descending order? Official documentation is not - much - help. Or what if I wanted to specify a key function? That's also supported: mylist.sort(key=lamba item: item.customVar)- but documented...where? I understand that Python's approach to OOP may not be equivalent to Java et. al. Maybe list isn't actually a class - maybe it's just a function that returns an iterable when the tachyon beams are set to glorious and the unboxed hyper enumeration is quantized, but...I don't care. I just want to know how to sort lists. (Apologies for the angst - too much caffeine today)

    Read the article

  • Are there any radix/patricia/critbit trees for Python?

    - by Andrew Dalke
    I have about 10,000 words used as a set of inverted indices to about 500,000 documents. Both are normalized so the index is a mapping of integers (word id) to a set of integers (ids of documents which contain the word). My prototype uses Python's set as the obvious data type. When I do a search for a document I find the list of N search words and their corresponding N sets. I want to return the set of documents in the intersection of those N sets. Python's "intersect" method is implemented as a pairwise reduction. I think I can do better with a parallel search of sorted sets, so long as the library offers a fast way to get the next entry after i. I've been looking for something like that for some time. Years ago I wrote PyJudy but I no longer maintain it and I know how much work it would take to get it to a stage where I'm comfortable with it again. I would rather use someone else's well-tested code, and I would like one which supports fast serialization/deserialization. I can't find any, or at least not any with Python bindings. There is avltree which does what I want, but since even the pair-wise set merge take longer than I want, I suspect I want to have all my operations done in C/C++. Do you know of any radix/patricia/critbit tree libraries written as C/C++ extensions for Python? Failing that, what is the most appropriate library which I should wrap? The Judy Array site hasn't been updated in 6 years, with 1.0.5 released in May 2007. (Although it does build cleanly so perhaps It Just Works.)

    Read the article

  • Download MMS content on Blackberry

    - by Chris
    Hi I am relatively new to coding for the blackberry and I need to write a java application that can capture all incoming and outgoing MMS data from a Blackberry device. I have gotten the capturing of outgoing MMS's sorted with the use of A sendListener, but the problem comes with the incoming MMS's. If I use a MessageListener that processes only those of type BinaryMessage, i can capture the binary notification SMS that comes in when there is an incoming MMS. From this notification, i can get the senders MSISDN as well as the URL on the MMSC where the content is stored. To get the actual MMS content, i presume i need to download it from this URL, but im unable to get this working. I have tried just opening a HTTPConnetion to this URL, opening an inputStream on it and reading from there, but i retrieve no content. If i manually go to that URL on the blackberry, i can see the content fine (and of course the blackberry can download it automatically anyway). Can anyone please help me asap on how i can get the mms content for incoming MMS's. Thanks alot

    Read the article

< Previous Page | 114 115 116 117 118 119 120 121 122 123 124 125  | Next Page >