Search Results

Search found 9431 results on 378 pages for 'bubble sort'.

Page 10/378 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • How do I sort an array of Person Objects by using compareto()?

    - by Adam
    Here is my code: > import java.util.Scanner; import java.util.Arrays; /** This class tests the Person class. */ public class PersonDemo { public static void main(String[] args) { int count = 0; Scanner in = new Scanner(System.in); boolean more = false; Person first = null; Person last = null; while (more) { System.out.println( "Please enter the person's name or a blank line to quit"); String name = in.nextLine(); if (name.equals("")) more = false; else { Person p = new Person(name); //new person object created with inputted name Person[] people = new Person[10]; //new array of 10 person objects people[count] = p; //declare person object with index of variable count as the new person object first = people[count]; // I have no idea what to do here. This is where I'm stuck. last = people[count]; // I can't figure out what to do with this either. first.compareTo(p); //call compareTo method on first and new person object last.compareTo(p); //call compareTo method on last and new person object count++; // increase count variable } } System.out.println("First: " + first.toString()); System.out.println("Last: " + last.toString()); } } And the Person class: /** A person with a name. */ public class Person implements Comparable { /** * Constructs a Person with a name. * @param aName the person's name */ public Person(String aName) { name = aName; } public String getName() { return name; } @Override public int compareTo(Object otherObject) { Person other = (Person)otherObject; if (name.compareTo(other.name) < 0) return -1; if (name.compareTo(other.name) > 0) return 1; return 0; } /** Returns a string representation of the object. @return name of Person */ public String toString() { return "[name=" + name + "]"; } private String name; }

    Read the article

  • Mocking Sort With Mocha

    - by josephmate
    How can I mock an array's sort expect a lambda expression? This is a trivial example of my problem: # initializing the data l = lambda { |a,b| a <=> b } array = [ 1, 2, 3, 4, 5 ] sorted_array = [ 2, 3, 8, 9, 1] # I expect that sort will be called using the lambda as a parameter array.expects(:sort).with( l ).returns( sorted_array ) # perform the sort using the lambda expression temp = array.sort{|a,b| l.call(a,b) } Now, at first I expected that this would work; however, I got the following error: - expected exactly once, not yet invoked: [ 1, 2, 3, 4, 5 ].sort(#<Proc:0xb665eb48>) Is there a way to do what I am looking for? Cheers, Joseph

    Read the article

  • Why wont this sort in Solr work?

    - by Camran
    I need to sort on a date-field type, which name is "mod_date". It works like this in the browser adress-bar: http://localhost:8983/solr/select/?&q=bmw&sort=mod_date+desc But I am using a phpSolr client which sends an URL to Solr, and the url sent is this: fq=+category%3A%22Bilar%22+%2B+car_action%3AS%C3%A4ljes&version=1.2&wt=json&json.nl=map&q=%2A%3A%2A&start=0&rows=5&sort=mod_date+desc // This wont work and is echoed after this in php: $queryString = http_build_query($params, null, $this->_queryStringDelimiter); $queryString = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $queryString); This wont work, I dont know why! Everything else works fine, all right fields are returned. But the sort doesn't work. Any ideas? Thanks BTW: The field "mod_date" contains something like: 2010-03-04T19:37:22.5Z EDIT: First I use PHP to send this to a SolrPhpClient which is another php-file called service.php: require_once('../SolrPhpClient/Apache/Solr/Service.php'); $solr = new Apache_Solr_Service('localhost', 8983, '/solr/'); $results = $solr->search($querystring, $p, $limit, $solr_params); $solr_params is an array which contains the solr-parameters (q, fq, etc). Now, in service.php: $params['version'] = self::SOLR_VERSION; // common parameters in this interface $params['wt'] = self::SOLR_WRITER; $params['json.nl'] = $this->_namedListTreatment; $params['q'] = $query; $params['sort'] = 'mod_date desc'; // HERE IS THE SORT I HAVE PROBLEM WITH $params['start'] = $offset; $params['rows'] = $limit; $queryString = http_build_query($params, null, $this->_queryStringDelimiter); $queryString = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $queryString); if ($method == self::METHOD_GET) { return $this->_sendRawGet($this->_searchUrl . $this->_queryDelimiter . $queryString); } else if ($method == self::METHOD_POST) { return $this->_sendRawPost($this->_searchUrl, $queryString, FALSE, 'application/x-www-form-urlencoded'); } The $results contain the results from Solr... So this is the way I need to get to work (via php). This code below (also on top of this Q) works but thats because I paste it into the adress bar manually, not via the PHPclient. But thats just for debugging, I need to get it to work via the PHPclient: http://localhost:8983/solr/select/?&q=bmw&sort=mod_date+des // Not via phpclient, but works UPDATE (2010-03-08): I have tried Donovans codes (the urls) and they work fine. Now, I have noticed that it is one of the parameters causing the 'SORT' not to work. This parameter is the "wt" parameter. If we take the url from top of this Q, (fq=+category%3A%22Bilar%22+%2B+car_action%3AS%C3%A4ljes&version=1.2&wt=json&json.nl=map&q=%2A%3A%2A&start=0&rows=5&sort=mod_date+desc), and just simply remove the "wt" parameter, then the sort works. BUT the results appear differently, thus making my php code not able to recognize the results I believe. Donovan would know this I think. I am guessing in order for the PHPClient to work, the results must be in a specific structure, which gets messed up as soon as I remove the wt parameter. Donovan, help me please... Here is some background what I use your SolrPhpClient for: I have a classifieds website, which uses MySql. But for the searching I am using Solr to search some indexed fields. Then Solr returns an array of ID:numbers (for all matches of the search criteria). Then I use those ID:numbers to find everything in a MySql db and fetch all other information (example is not searchable information). So simplified: Search - Solr returns all matches in an array of ID:nrs - Id:numbers from Solr are the same as the Id numbers in the MySql db, so I can just make a simple match agains every record with the ID matching the ID from the Solr results array. I don't use Faceting, no boosting, no relevancy or other fancy stuff. I only sort by the latest classified put, and give the option to users to also sort on the cheapest price. Nothing more. Then I use the "fq" parameter to do queries on different fields in Solr depending on category chosen by users (example "cars" in this case which in my language is "Bilar"). I am really stuck with this problem here... Thanks for all help

    Read the article

  • Confused about GNU `sort(1)` of a numerical sub field

    - by Chen Levy
    I wish to sort a space separated table, with the numerical value that found on the 2nd field. I can assume that the 2nd field is always fooN but the length of N is unknown: antiq. foo11 girls colleaguing foo2 Leinsdorf Cousy foo0 Montgomeryville bowlegged foo1 pollack Chevrier foo10 ill-conceived candlebomb foo3 seventieths autochthony foo101 re-enable beneficiate foo100 osteometric I read man sort(1) and played with all sort of options. On my system I found the line: sort -n -k2.5 table to work. My question is why? According to the man page: -k, --key=POS1[,POS2] start a key at POS1, end it at POS 2 (origin 1) ... POS is F[.C][OPTS], where F is the field number and C the characterposition in the field. OPTS is one or more single-letter ordering options, which override global ordering options for that key. If no key is given, use the entire line as the key. So why sort -n -k2.4 table don't work and sort -n -k.5 does?

    Read the article

  • Sort a GridView Column related to other Table

    - by Tim
    Hello, i have a GridView bound to a DataView. Some columns in the DataView's table are foreignkeys to related tables(f.e. Customer). I want to enable sorting for these columns too, but all i can do is sorting the foreignkey(fiCustomer) and not the CustomerName. I have tried this without success(" Cannot find column ERP_Customer.CustomerName "): <asp:TemplateField HeaderText="Customer" SortExpression="ERP_Customer.CustomerName" > A tried also the DataViewManager, but i've a problem to detect the table to sort: Dim viewManager As New DataViewManager(Me.dsERP) viewManager.DataViewSettings(dsERP.ERP_Charge).RowFilter = filter viewManager.DataViewSettings(dsERP.ERP_Charge).Sort = sort 'sort is the GridView's SortExpression Me.GrdCharge.DataSource = viewManager.CreateDataView(dsERP.ERP_Charge) I have to apply the sort on a distinct table of the DataViewManager, but this table would differ on the related tables. I have bound the TemplateColumns in Codebehind in RowDataBound-Event f.e.: Dim LblCustomer As Label = DirectCast(e.Row.FindControl("LblCustomer"), Label) LblCustomer.Text = drCharge.ERP_CustomerRow.CustomerName 'drCharge inherits DataRow What is the recommended way to sort a GridView on columns related to another table?

    Read the article

  • Mysql select most frequent and sort alphabetically

    - by user2605793
    I am trying to select the most common 100 names from a table then display the list showing the names and count. I want the user to be able to re-sort the list alphabetically rather than based on count. I thought the following code would do it. It works for the default sort by count but fails on the sort alphabetically. The line "$count = mysql_num_rows($table);" gives an error: mysql_num_rows() expects parameter 1 to be resource, boolean given. Any help would be greatly appreciated. // Get most popular surnames echo '<h2>Most Common Surnames</h2>'; if ($sort == "") { // default sort by count echo '<a href="http://mysite/names.php?id='.$id.'&sort=name">Sort by name</a><br>'; $query = "SELECT family_name, COUNT(*) as count FROM namefile WHERE record_key = $id GROUP BY family_name ORDER BY count DESC LIMIT 100"; } else { // sort alphabetically echo '<a href="http://mysite/names.php?id='.$id.'">Sort by count</a><br>'; $query = "SELECT * FROM ( SELECT family_name, COUNT(*) as count FROM namefile WHERE record_key = $id GROUP BY family_name ORDER BY count DESC LIMIT 100) AS alpha ORDER BY family_name"; } $table = mysql_query($query); $count = mysql_num_rows($table); $tot = 0; $i = 0; echo '<table><tr>'; while ($tot < $count2) { $rec2 = mysql_fetch_array($table2); echo '<td>'.$rec2[0].'</td><td>'.$rec2[1].'</td><td width="40">&nbsp;</td><td>'; if ($i++ == 6) { echo '</tr><tr>'; $i = 0; } $tot++; } echo '</tr></table><br>'; UPDATE: I needed to add "AS alpha" to give the outer select a unique name. (alpha is just a random name I made up.) It now works perfectly. Code updated for the benefit of any others who need something similar.

    Read the article

  • Method to sort MYSQL results by an arbitriary letter (ie, show all rows starting with F first)

    - by Buzz
    I have a column of states, and, depending on the query, I want to order by results by a particular state, then by id (Asc or Desc, depending). For instance, I might want to show all rows with state "HI", sorted by ID desc, and then all the other rows, sorted by id desc. I was hoping I could do this in one query, rather than getting all my favored state results, and then getting the rest. Can I?

    Read the article

  • Algorithm of JavaScript "sort()" Function

    - by Knowledge Craving
    Recently when I was working with JavaScript "sort()" function, I found in one of the tutorials that this function does not sort the numbers properly. Instead to sort numbers, a function must be added that compares numbers, like the following code:- <script type="text/javascript"> function sortNumber(a,b) { return a - b; } var n = ["10", "5", "40", "25", "100", "1"]; document.write(n.sort(sortNumber)); </script> The output then comes as:- 1,5,10,25,40,100 Now what I didn't understand is that why is this occurring & can anybody please tell in details as to what type of algorithm is being used in this "sort()" function? This is because for any other language, I didn't find this problem where the function didn't sort the numbers correctly. Any help is greatly appreciated.

    Read the article

  • Sort Your Emails by Conversation in Outlook 2010

    - by Matthew Guay
    Do you prefer the way Gmail sorts your emails by conversation?  Here’s how you can use this handy feature in Outlook 2010 too. One exciting new feature in Outlook 2010 is the ability to sort and link your emails by conversation.  This makes it easier to know what has been discussed in emails, and helps you keep your inbox more tidy.  Some users don’t like their emails linked into conversations, and in the final release of Outlook 2010 it is turned off by default.  Since this is a new feature, new users may overlook it and never know it’s available.  Here’s how you can enable conversation view and keep your email conversations accessible and streamlined. Activate Conversation View By default, your inbox in Outlook 2010 will look much like it always has in Outlook…a list of individual emails. To view your emails by conversation, select the View tab and check the Show as Conversations box on the top left. Alternately, click on the Arrange By tab above your emails, and select Show as Conversations. Outlook will ask if you want to activate conversation view in only this folder or all folders.  Choose All folders to view all emails in Outlook in conversations. Outlook will now resort your inbox, linking emails in the same conversation together.  Individual emails that don’t belong to a conversation will look the same as before, while conversations will have a white triangle carrot on the top left of the message title.  Select the message to read the latest email in the conversation. Or, click the triangle to see all of the messages in the conversation.  Now you can select and read any one of them. Most email programs and services include the previous email in the body of an email when you reply.  Outlook 2010 can recognize these previous messages as well.  You can navigate between older and newer messages from popup Next and Previous buttons that appear when you hover over the older email’s header.  This works both in the standard Outlook preview pane and when you open an email in its own window.   Edit Conversation View Settings Back in the Outlook View tab, you can tweak your conversation view to work the way you want.  You can choose to have Outlook Always Expand Conversations, Show Senders Above the Subject, and to Use Classic Indented View.  By default, Outlook will show messages from other folders in the conversation, which is generally helpful; however, if you don’t like this, you can uncheck it here.  All of these settings will stay the same across all of your Outlook accounts. If you choose Indented View, it will show the title on the top and then an indented message entry underneath showing the name of the sender. The Show Senders Above the Subject view makes it more obvious who the email is from and who else is active in the conversation.  This is especially useful if you usually only email certain people about certain topics, making the subject lines less relevant. Or, if you decide you don’t care for conversation view, you can turn it off by unchecking the box in the View tab as above. Conclusion Although it may take new users some time to get used to, conversation view can be very helpful in keeping your inbox organized and letting important emails stay together.  If you’re a Gmail user syncing your email account with Outlook, you may find this useful as it makes Outlook 2010 work more like Gmail, even when offline. If you’d like to sync your Gmail account with Outlook 2010, check out our articles on syncing it with POP3 and IMAP. Similar Articles Productive Geek Tips Automatically Move Daily Emails to Specific Folders in OutlookQuickly Clean Your Inbox in Outlook 2003/2007Find Emails With Attachments with Outlook 2007’s Instant SearchAdd Your Gmail Account to Outlook 2010 using POPSchedule Auto Send & Receive in Microsoft Outlook TouchFreeze Alternative in AutoHotkey The Icy Undertow Desktop Windows Home Server – Backup to LAN The Clear & Clean Desktop Use This Bookmarklet to Easily Get Albums Use AutoHotkey to Assign a Hotkey to a Specific Window Latest Software Reviews Tinyhacker Random Tips CloudBerry Online Backup 1.5 for Windows Home Server Snagit 10 VMware Workstation 7 Acronis Online Backup The iPod Revolution Ultimate Boot CD can help when disaster strikes Windows Firewall with Advanced Security – How To Guides Sculptris 1.0, 3D Drawing app AceStock, a Tiny Desktop Quote Monitor Gmail Button Addon (Firefox)

    Read the article

  • How to "bubble" a Controls features when place in a custom UserControl

    - by Ted
    I'll try to explain what Im after. I dont know the technical term for it, so here goes: Example 1: If I place a LisView on a Form and add som columns I am able, in Design-Time, to click-and-drag the columns to resize them. Example 2: Now, I place a ListView in a UserControl and name it "MyCustomListView" (and perhaps add some method to enhance it somehow). If I know place the "MyCustomListView" on a Form I am unable to click-and-drag the column headers to resize them in Design-Time. Is there any way to easily make that happen? Some form of "pass the click-and-drag event to the underlying control and let that control do its magic". Im not really looking to recode, just pass on the mouseclick (or whatever it is) and let the, in this case, ListView react as it did in the first example above. Regards

    Read the article

  • Sort order in Windows Explorer

    - by Haim H.
    The behaviour described below occurs on Windows-7 systems and on Windows XP. We operate in a dual-language environment - English and Hebrew. When in Windows Explorer we sort files by name, the order in which they are listed is not what we would expect. Here is a list of file names as sorted by Windows Explorer (all of the files have a .pdf suffix): 1G110033H-PP 19C050G-PP-ORB 19C050H-PPRM 19C100H-PPRM 19C-MBPS-PP 19C-MBPS-PP-1 29AAC050-PP 29AAC100-PP 29AAC100-PPUL 29B004064-PP 101AC050-PP 101AC100-PP 101B100-PPE 1091003G-PPFSUL 10108033G-PPSA 10125033H-PPM It looks to me that first the items are sorted according to the position of the first alphabetic character in the name, and then, within those groups, they are sorted in "normal" alpha-numeric order. That is, all the files with an alpha character in the first position are on top of the list, followed by those with the first alpha character in the second position, followed by those with the first alpha character in the third position, and so on. An alternate way of looking at this is that, in a file name composed of numbers and letters, the sort treats the first group of numbers in the name as the major sort node, with the rest of the name being the secondary sort node. Now that I understand the sequencing logic, it's not a big problem, but I was wondering why this happens?

    Read the article

  • PLT Scheme sort function

    - by Danny
    PLT Scheme guide says that it's implemented sort function is able to sort a list according to an extarcted value using a lambda function. link text The guide provides an unworking code example of this- (sort '(("aardvark") ("dingo") ("cow") ("bear")) #:key car string<?) Which returns an error. How is this function is supposed to be calles so that it will actually sort a list according to values calculated by a given function?

    Read the article

  • xcode user script - Apple Script - Sort selected lines by length

    - by Bach
    I need to create a user scripts in xcode where I can sort a selection of multiple lines, by their length (number of characters) I know of this macro variable PBXTextLength, but not sure how to write the script. this is the sort selection script in Xcode: echo -n "%%%{PBXSelection}%%%" sort <&0 echo -n "%%%{PBXSelection}%%%" how can i modify that script to sort the selection by the length of the line (PBXTextLength)? thanks

    Read the article

  • UItextView in UITableview, autocorrection bubble not visible

    - by f0rz
    Hello! I have a UITableView with custom cells. The cells containing one UITextView each and the cell is resizing during user type text in the TextView. My problem is when user is on first row in a TextView autocorrection bubbles wont be visible in the current cell. Is there any workaround or can someone point me to another direction?

    Read the article

  • how to use sort function the same way as max or min in mathematica

    - by Qiang Li
    Please take a look at the following code: Sort[{1, y, x}, Greater] Max[{1, x, y}] x = 1 y = 2 Sort[{1, y, x}, Greater] Max[{1, x, y}] It is interesting to note that the first Sort always produce a definite result while the first Max does not, even when Greater is specified. Note I have not given any numerical values for x and y. Why is this and how can I have a Sort function behave the same way as the Max (or Min) function? Thanks!

    Read the article

  • Exception in the OnIdle event does not bubble up

    - by sthay
    On my main form, I subscribed to two events: Application.ThreadException and Application.Idle. In theory, any exception that is not caught should get bubbled up to the main form. However, this does not work if the exception happens in the OnIdle event. The system just crashes. Does anyone know how to solve this problem? Thanks so much.

    Read the article

  • How To Run XP Mode in VirtualBox on Windows 7 (sort of)

    - by Matthew Guay
    A few weeks ago we showed you how to run XP Mode on a Windows 7 computer without Hardware Virtualization using VMware. Some of you have been asking if it can be done in Virtual Box as well. The answer is “Yes!” and here we’ll show you how. Editor Update: Apparently there isn’t a way to activate XP Mode through VirtualBox using this method. You will however, be able to run it for 30 days. We have a new updated article on how to Install XP Mode with VirtualBox Using the VMLite Plugin.   Earlier we showed you how to run XP mode on windows 7 machines without hardware virtualization capability. Since then, a lot of you have been asking to a write up a tutorial about doing the same thing using VirtualBox.  This makes it another great way to run XP Mode if your computer does not have hardware virtualization.  Here we’ll see how to import the XP Mode from Windows 7 Professional, Enterprise, or Ultimate into VirtualBox so you can run XP in it for free. Note: You need to have Windows 7 Professional or above to use XP Mode in this manner. In our tests we were able to get it to run on Home Premium as well, but you’ll be breaking Windows 7 licensing agreements. Getting Started First, download and install XP Mode (link below).  There is no need to download Virtual PC if your computer cannot run it, so just download the XP Mode from the link on the left. Install XP mode; just follow the default prompts as usual. Now, download and install VirtualBox 3.1.2 or higher(link below).  Install as normal, and simply follow the default prompts. VirtualBox may notify you that your network connection will be reset during the installation.  Press Yes to continue. During the install, you may see several popups asking you if you wish to install device drivers for USB and Network interfaces.  Simply click install, as these are needed for VirtualBox to run correctly. Setup only took a couple minutes, and doesn’t require a reboot. Setup XP Mode in VirtualBox: First we need to copy the default XP Mode so VirtualBox will not affect the original copy.  Browse to C:\Program Files\Windows XP Mode, and copy the file “Windows XP Mode base.vhd”.  Paste it in another folder of your choice, such as your Documents folder. Once you’ve copied the file, right-click on it and click Properties. Uncheck the “Read-only” box in this dialog, and then click Ok. Now, in VirtualBox, click New to create a new virtual machine. Enter the name of your virtual machine, and make sure the operating system selected is Windows XP. Choose how much memory you want to allow the virtual machine to use.  VirtualBox’ default is 192 Mb ram, but for better performance you can select 256 or 512Mb. Now, select the hard drive for the virtual machine.  Select “Use existing hard disk”, then click the folder button to choose the XP Mode virtual drive. In this window, click Add, and then browse to find the copy of XP Mode you previously made. Make sure the correct virtual drive is selected, then press Select. After selecting the VHD your screen should look like the following then click Next. Verify the settings you made are correct. If not, you can go back and make any changes. When everything looks correct click Finish. Setup XP Mode Now, in VirtualBox, click start to run XP Mode. The Windows XP in this virtual drive is not fully setup yet, so you will have to go through the setup process.   If you didn’t uncheck the “Read-only” box in the VHD properties before, you may see the following error.  If you see it, go back and check the file to makes sure it is not read-only. When you click in the virtual machine, it will capture your mouse by default.  Simply press the right Ctrl key to release your mouse so you can go back to using Windows 7.  This will only be the case during the setup process; after the Guest Additions are installed, the mouse will seamlessly move between operating systems. Now, accept the license agreement in XP.   Choose your correct locale and keyboard settings. Enter a name for your virtual XP, and an administrative password. Check the date, time, and time zone settings, and adjust them if they are incorrect.  The time and date are usually correct, but the time zone often has to be corrected. XP will now automatically finish setting up your virtual machine, and then will automatically reboot. After rebooting, select your automatic update settings. You may see a prompt to check for drivers; simply press cancel, as all the drivers we need will be installed later with the Guest Additions. Your last settings will be finalized, and finally you will see your XP desktop in VirtualBox. Please note that XP Mode may not remain activated after importing it into VirtualBox. When you activate it, use the key that is located at C:\Program Files\Windows XP Mode\key.txt.  Note: During our tests we weren’t able to get the activation to go through. We are looking into the issue and will have a revised article showing the correct way to get XP Mode in VirutalBox working correctly soon.    Now we have one final thing to install – the VirtualBox Guest Additions.  In the VirtualBox window, click “Devices” and then select “Install Guest Additions”. This should automatically launch in XP; if it doesn’t, click Start, then My Computer, and finally double-click on the CD drive which should say VirtualBox Guest Additions. Simply install with the normal presets. You can select to install an experimental 3D graphics driver if you wish to try to run games in XP in VirtualBox; however, do note that this is not fully supported and is currently a test feature. You may see a prompt informing you that the drivers have not passed Logo testing; simply press “Continue Anyway” to proceed with the installation.   When installation has completed, you will be required to reboot your virtual machine. Now, you can move your mouse directly from Windows XP to Windows 7 without pressing Ctrl. Integrating with Windows 7 Once your virtual machine is rebooted, you can integrate it with your Windows 7 desktop.  In the VirtualBox window, click Machine and then select “Seamless Mode”.   In Seamless mode you’ll have the XP Start menu and taskbar sit on top of your Windows 7 Start and Taskbar. Here we see XP running on Virtual Box in Seamless Mode. We have the old XP WordPad sitting next to the new Windows 7 version of WordPad. Another view of everything running seamlessly together on the same Windows 7 desktop. Hover the pointer over the XP taskbar to pull up the Virtual Box menu items. You can exit out of Seamless Mode from the VirtualBox menu or using “Ctrl+L”. Then you go back to having it run separately on your desktop again. Conclusion Running XP Mode in a Virtual Machine is a great way to experience the feature on computers without Hardware Virtualization capabilities. If you prefer VMware Player, then you’ll want to check out our articles on how to run XP Mode on Windows 7 machines without Hardware Virtualization, and how to create an XP Mode for Windows 7 Home Premium and Vista. Download VirtualBox Download XP Mode Similar Articles Productive Geek Tips Install XP Mode with VirtualBox Using the VMLite PluginUsing Windows 7 or Vista Compatibility ModeMake Safari Stop Crashing Every 20 Seconds on Windows VistaForce Windows 7 / Vista to Boot Into Safe Mode Without Using the F8 KeyHow To Run Chrome OS in VirtualBox TouchFreeze Alternative in AutoHotkey The Icy Undertow Desktop Windows Home Server – Backup to LAN The Clear & Clean Desktop Use This Bookmarklet to Easily Get Albums Use AutoHotkey to Assign a Hotkey to a Specific Window Latest Software Reviews Tinyhacker Random Tips Revo Uninstaller Pro Registry Mechanic 9 for Windows PC Tools Internet Security Suite 2010 PCmover Professional Enable Check Box Selection in Windows 7 OnlineOCR – Free OCR Service Betting on the Blind Side, a Vanity Fair article 30 Minimal Logo Designs that Say More with Less LEGO Digital Designer – Free Create a Personal Website Quickly using Flavors.me

    Read the article

  • How To Run XP Mode in VirtualBox on Windows 7 (sort of)

    - by Matthew Guay
    A few weeks ago we showed you how to run XP Mode on a Windows 7 computer without Hardware Virtualization using VMware. Some of you have been asking if it can be done in Virtual Box as well. The answer is “Yes!” and here we’ll show you how. Editor Update: Apparently there isn’t a way to activate XP Mode through VirtualBox using this method. You will however, be able to run it for 30 days. We have a new updated article on how to Install XP Mode with VirtualBox Using the VMLite Plugin.   Earlier we showed you how to run XP mode on windows 7 machines without hardware virtualization capability. Since then, a lot of you have been asking to a write up a tutorial about doing the same thing using VirtualBox.  This makes it another great way to run XP Mode if your computer does not have hardware virtualization.  Here we’ll see how to import the XP Mode from Windows 7 Professional, Enterprise, or Ultimate into VirtualBox so you can run XP in it for free. Note: You need to have Windows 7 Professional or above to use XP Mode in this manner. In our tests we were able to get it to run on Home Premium as well, but you’ll be breaking Windows 7 licensing agreements. Getting Started First, download and install XP Mode (link below).  There is no need to download Virtual PC if your computer cannot run it, so just download the XP Mode from the link on the left. Install XP mode; just follow the default prompts as usual. Now, download and install VirtualBox 3.1.2 or higher(link below).  Install as normal, and simply follow the default prompts. VirtualBox may notify you that your network connection will be reset during the installation.  Press Yes to continue. During the install, you may see several popups asking you if you wish to install device drivers for USB and Network interfaces.  Simply click install, as these are needed for VirtualBox to run correctly. Setup only took a couple minutes, and doesn’t require a reboot. Setup XP Mode in VirtualBox: First we need to copy the default XP Mode so VirtualBox will not affect the original copy.  Browse to C:\Program Files\Windows XP Mode, and copy the file “Windows XP Mode base.vhd”.  Paste it in another folder of your choice, such as your Documents folder. Once you’ve copied the file, right-click on it and click Properties. Uncheck the “Read-only” box in this dialog, and then click Ok. Now, in VirtualBox, click New to create a new virtual machine. Enter the name of your virtual machine, and make sure the operating system selected is Windows XP. Choose how much memory you want to allow the virtual machine to use.  VirtualBox’ default is 192 Mb ram, but for better performance you can select 256 or 512Mb. Now, select the hard drive for the virtual machine.  Select “Use existing hard disk”, then click the folder button to choose the XP Mode virtual drive. In this window, click Add, and then browse to find the copy of XP Mode you previously made. Make sure the correct virtual drive is selected, then press Select. After selecting the VHD your screen should look like the following then click Next. Verify the settings you made are correct. If not, you can go back and make any changes. When everything looks correct click Finish. Setup XP Mode Now, in VirtualBox, click start to run XP Mode. The Windows XP in this virtual drive is not fully setup yet, so you will have to go through the setup process.   If you didn’t uncheck the “Read-only” box in the VHD properties before, you may see the following error.  If you see it, go back and check the file to makes sure it is not read-only. When you click in the virtual machine, it will capture your mouse by default.  Simply press the right Ctrl key to release your mouse so you can go back to using Windows 7.  This will only be the case during the setup process; after the Guest Additions are installed, the mouse will seamlessly move between operating systems. Now, accept the license agreement in XP.   Choose your correct locale and keyboard settings. Enter a name for your virtual XP, and an administrative password. Check the date, time, and time zone settings, and adjust them if they are incorrect.  The time and date are usually correct, but the time zone often has to be corrected. XP will now automatically finish setting up your virtual machine, and then will automatically reboot. After rebooting, select your automatic update settings. You may see a prompt to check for drivers; simply press cancel, as all the drivers we need will be installed later with the Guest Additions. Your last settings will be finalized, and finally you will see your XP desktop in VirtualBox. Please note that XP Mode may not remain activated after importing it into VirtualBox. When you activate it, use the key that is located at C:\Program Files\Windows XP Mode\key.txt.  Note: During our tests we weren’t able to get the activation to go through. We are looking into the issue and will have a revised article showing the correct way to get XP Mode in VirutalBox working correctly soon.    Now we have one final thing to install – the VirtualBox Guest Additions.  In the VirtualBox window, click “Devices” and then select “Install Guest Additions”. This should automatically launch in XP; if it doesn’t, click Start, then My Computer, and finally double-click on the CD drive which should say VirtualBox Guest Additions. Simply install with the normal presets. You can select to install an experimental 3D graphics driver if you wish to try to run games in XP in VirtualBox; however, do note that this is not fully supported and is currently a test feature. You may see a prompt informing you that the drivers have not passed Logo testing; simply press “Continue Anyway” to proceed with the installation.   When installation has completed, you will be required to reboot your virtual machine. Now, you can move your mouse directly from Windows XP to Windows 7 without pressing Ctrl. Integrating with Windows 7 Once your virtual machine is rebooted, you can integrate it with your Windows 7 desktop.  In the VirtualBox window, click Machine and then select “Seamless Mode”.   In Seamless mode you’ll have the XP Start menu and taskbar sit on top of your Windows 7 Start and Taskbar. Here we see XP running on Virtual Box in Seamless Mode. We have the old XP WordPad sitting next to the new Windows 7 version of WordPad. Another view of everything running seamlessly together on the same Windows 7 desktop. Hover the pointer over the XP taskbar to pull up the Virtual Box menu items. You can exit out of Seamless Mode from the VirtualBox menu or using “Ctrl+L”. Then you go back to having it run separately on your desktop again. Conclusion Running XP Mode in a Virtual Machine is a great way to experience the feature on computers without Hardware Virtualization capabilities. If you prefer VMware Player, then you’ll want to check out our articles on how to run XP Mode on Windows 7 machines without Hardware Virtualization, and how to create an XP Mode for Windows 7 Home Premium and Vista. Download VirtualBox Download XP Mode Similar Articles Productive Geek Tips Install XP Mode with VirtualBox Using the VMLite PluginUsing Windows 7 or Vista Compatibility ModeMake Safari Stop Crashing Every 20 Seconds on Windows VistaForce Windows 7 / Vista to Boot Into Safe Mode Without Using the F8 KeyHow To Run Chrome OS in VirtualBox TouchFreeze Alternative in AutoHotkey The Icy Undertow Desktop Windows Home Server – Backup to LAN The Clear & Clean Desktop Use This Bookmarklet to Easily Get Albums Use AutoHotkey to Assign a Hotkey to a Specific Window Latest Software Reviews Tinyhacker Random Tips Revo Uninstaller Pro Registry Mechanic 9 for Windows PC Tools Internet Security Suite 2010 PCmover Professional Enable Check Box Selection in Windows 7 OnlineOCR – Free OCR Service Betting on the Blind Side, a Vanity Fair article 30 Minimal Logo Designs that Say More with Less LEGO Digital Designer – Free Create a Personal Website Quickly using Flavors.me

    Read the article

  • Sorting Algorithms

    - by MarkPearl
    General Every time I go back to university I find myself wading through sorting algorithms and their implementation in C++. Up to now I haven’t really appreciated their true value. However as I discovered this last week with Dictionaries in C# – having a knowledge of some basic programming principles can greatly improve the performance of a system and make one think twice about how to tackle a problem. I’m going to cover briefly in this post the following: Selection Sort Insertion Sort Shellsort Quicksort Mergesort Heapsort (not complete) Selection Sort Array based selection sort is a simple approach to sorting an unsorted array. Simply put, it repeats two basic steps to achieve a sorted collection. It starts with a collection of data and repeatedly parses it, each time sorting out one element and reducing the size of the next iteration of parsed data by one. So the first iteration would go something like this… Go through the entire array of data and find the lowest value Place the value at the front of the array The second iteration would go something like this… Go through the array from position two (position one has already been sorted with the smallest value) and find the next lowest value in the array. Place the value at the second position in the array This process would be completed until the entire array had been sorted. A positive about selection sort is that it does not make many item movements. In fact, in a worst case scenario every items is only moved once. Selection sort is however a comparison intensive sort. If you had 10 items in a collection, just to parse the collection you would have 10+9+8+7+6+5+4+3+2=54 comparisons to sort regardless of how sorted the collection was to start with. If you think about it, if you applied selection sort to a collection already sorted, you would still perform relatively the same number of iterations as if it was not sorted at all. Many of the following algorithms try and reduce the number of comparisons if the list is already sorted – leaving one with a best case and worst case scenario for comparisons. Likewise different approaches have different levels of item movement. Depending on what is more expensive, one may give priority to one approach compared to another based on what is more expensive, a comparison or a item move. Insertion Sort Insertion sort tries to reduce the number of key comparisons it performs compared to selection sort by not “doing anything” if things are sorted. Assume you had an collection of numbers in the following order… 10 18 25 30 23 17 45 35 There are 8 elements in the list. If we were to start at the front of the list – 10 18 25 & 30 are already sorted. Element 5 (23) however is smaller than element 4 (30) and so needs to be repositioned. We do this by copying the value at element 5 to a temporary holder, and then begin shifting the elements before it up one. So… Element 5 would be copied to a temporary holder 10 18 25 30 23 17 45 35 – T 23 Element 4 would shift to Element 5 10 18 25 30 30 17 45 35 – T 23 Element 3 would shift to Element 4 10 18 25 25 30 17 45 35 – T 23 Element 2 (18) is smaller than the temporary holder so we put the temporary holder value into Element 3. 10 18 23 25 30 17 45 35 – T 23   We now have a sorted list up to element 6. And so we would repeat the same process by moving element 6 to a temporary value and then shifting everything up by one from element 2 to element 5. As you can see, one major setback for this technique is the shifting values up one – this is because up to now we have been considering the collection to be an array. If however the collection was a linked list, we would not need to shift values up, but merely remove the link from the unsorted value and “reinsert” it in a sorted position. Which would reduce the number of transactions performed on the collection. So.. Insertion sort seems to perform better than selection sort – however an implementation is slightly more complicated. This is typical with most sorting algorithms – generally, greater performance leads to greater complexity. Also, insertion sort performs better if a collection of data is already sorted. If for instance you were handed a sorted collection of size n, then only n number of comparisons would need to be performed to verify that it is sorted. It’s important to note that insertion sort (array based) performs a number item moves – every time an item is “out of place” several items before it get shifted up. Shellsort – Diminishing Increment Sort So up to now we have covered Selection Sort & Insertion Sort. Selection Sort makes many comparisons and insertion sort (with an array) has the potential of making many item movements. Shellsort is an approach that takes the normal insertion sort and tries to reduce the number of item movements. In Shellsort, elements in a collection are viewed as sub-collections of a particular size. Each sub-collection is sorted so that the elements that are far apart move closer to their final position. Suppose we had a collection of 15 elements… 10 20 15 45 36 48 7 60 18 50 2 19 43 30 55 First we may view the collection as 7 sub-collections and sort each sublist, lets say at intervals of 7 10 60 55 – 20 18 – 15 50 – 45 2 – 36 19 – 48 43 – 7 30 10 55 60 – 18 20 – 15 50 – 2 45 – 19 36 – 43 48 – 7 30 (Sorted) We then sort each sublist at a smaller inter – lets say 4 10 55 60 18 – 20 15 50 2 – 45 19 36 43 – 48 7 30 10 18 55 60 – 2 15 20 50 – 19 36 43 45 – 7 30 48 (Sorted) We then sort elements at a distance of 1 (i.e. we apply a normal insertion sort) 10 18 55 60 2 15 20 50 19 36 43 45 7 30 48 2 7 10 15 18 19 20 30 36 43 45 48 50 55 (Sorted) The important thing with shellsort is deciding on the increment sequence of each sub-collection. From what I can tell, there isn’t any definitive method and depending on the order of your elements, different increment sequences may perform better than others. There are however certain increment sequences that you may want to avoid. An even based increment sequence (e.g. 2 4 8 16 32 …) should typically be avoided because it does not allow for even elements to be compared with odd elements until the final sort phase – which in a way would negate many of the benefits of using sub-collections. The performance on the number of comparisons and item movements of Shellsort is hard to determine, however it is considered to be considerably better than the normal insertion sort. Quicksort Quicksort uses a divide and conquer approach to sort a collection of items. The collection is divided into two sub-collections – and the two sub-collections are sorted and combined into one list in such a way that the combined list is sorted. The algorithm is in general pseudo code below… Divide the collection into two sub-collections Quicksort the lower sub-collection Quicksort the upper sub-collection Combine the lower & upper sub-collection together As hinted at above, quicksort uses recursion in its implementation. The real trick with quicksort is to get the lower and upper sub-collections to be of equal size. The size of a sub-collection is determined by what value the pivot is. Once a pivot is determined, one would partition to sub-collections and then repeat the process on each sub collection until you reach the base case. With quicksort, the work is done when dividing the sub-collections into lower & upper collections. The actual combining of the lower & upper sub-collections at the end is relatively simple since every element in the lower sub-collection is smaller than the smallest element in the upper sub-collection. Mergesort With quicksort, the average-case complexity was O(nlog2n) however the worst case complexity was still O(N*N). Mergesort improves on quicksort by always having a complexity of O(nlog2n) regardless of the best or worst case. So how does it do this? Mergesort makes use of the divide and conquer approach to partition a collection into two sub-collections. It then sorts each sub-collection and combines the sorted sub-collections into one sorted collection. The general algorithm for mergesort is as follows… Divide the collection into two sub-collections Mergesort the first sub-collection Mergesort the second sub-collection Merge the first sub-collection and the second sub-collection As you can see.. it still pretty much looks like quicksort – so lets see where it differs… Firstly, mergesort differs from quicksort in how it partitions the sub-collections. Instead of having a pivot – merge sort partitions each sub-collection based on size so that the first and second sub-collection of relatively the same size. This dividing keeps getting repeated until the sub-collections are the size of a single element. If a sub-collection is one element in size – it is now sorted! So the trick is how do we put all these sub-collections together so that they maintain their sorted order. Sorted sub-collections are merged into a sorted collection by comparing the elements of the sub-collection and then adjusting the sorted collection. Lets have a look at a few examples… Assume 2 sub-collections with 1 element each 10 & 20 Compare the first element of the first sub-collection with the first element of the second sub-collection. Take the smallest of the two and place it as the first element in the sorted collection. In this scenario 10 is smaller than 20 so 10 is taken from sub-collection 1 leaving that sub-collection empty, which means by default the next smallest element is in sub-collection 2 (20). So the sorted collection would be 10 20 Lets assume 2 sub-collections with 2 elements each 10 20 & 15 19 So… again we would Compare 10 with 15 – 10 is the winner so we add it to our sorted collection (10) leaving us with 20 & 15 19 Compare 20 with 15 – 15 is the winner so we add it to our sorted collection (10 15) leaving us with 20 & 19 Compare 20 with 19 – 19 is the winner so we add it to our sorted collection (10 15 19) leaving us with 20 & _ 20 is by default the winner so our sorted collection is 10 15 19 20. Make sense? Heapsort (still needs to be completed) So by now I am tired of sorting algorithms and trying to remember why they were so important. I think every year I go through this stuff I wonder to myself why are we made to learn about selection sort and insertion sort if they are so bad – why didn’t we just skip to Mergesort & Quicksort. I guess the only explanation I have for this is that sometimes you learn things so that you can implement them in future – and other times you learn things so that you know it isn’t the best way of implementing things and that you don’t need to implement it in future. Anyhow… luckily this is going to be the last one of my sorts for today. The first step in heapsort is to convert a collection of data into a heap. After the data is converted into a heap, sorting begins… So what is the definition of a heap? If we have to convert a collection of data into a heap, how do we know when it is a heap and when it is not? The definition of a heap is as follows: A heap is a list in which each element contains a key, such that the key in the element at position k in the list is at least as large as the key in the element at position 2k +1 (if it exists) and 2k + 2 (if it exists). Does that make sense? At first glance I’m thinking what the heck??? But then after re-reading my notes I see that we are doing something different – up to now we have really looked at data as an array or sequential collection of data that we need to sort – a heap represents data in a slightly different way – although the data is stored in a sequential collection, for a sequential collection of data to be in a valid heap – it is “semi sorted”. Let me try and explain a bit further with an example… Example 1 of Potential Heap Data Assume we had a collection of numbers as follows 1[1] 2[2] 3[3] 4[4] 5[5] 6[6] For this to be a valid heap element with value of 1 at position [1] needs to be greater or equal to the element at position [3] (2k +1) and position [4] (2k +2). So in the above example, the collection of numbers is not in a valid heap. Example 2 of Potential Heap Data Lets look at another collection of numbers as follows 6[1] 5[2] 4[3] 3[4] 2[5] 1[6] Is this a valid heap? Well… element with the value 6 at position 1 must be greater or equal to the element at position [3] and position [4]. Is 6 > 4 and 6 > 3? Yes it is. Lets look at element 5 as position 2. It must be greater than the values at [4] & [5]. Is 5 > 3 and 5 > 2? Yes it is. If you continued to examine this second collection of data you would find that it is in a valid heap based on the definition of a heap.

    Read the article

  • perl sorting an array of hashes

    - by srk
    use strict; my @arr; $arr[0][0]{5} = 16; $arr[0][1]{6} = 11; $arr[0][2]{7} = 25; $arr[0][3]{8} = 31; $arr[0][4]{9} = 16; $arr[0][5]{10} = 17; sort the array based on hash values so this should change to $arr[0][0]{6} = 11; $arr[0][1]{9} = 16; $arr[0][2]{5} = 16; $arr[0][3]{10} = 17; $arr[0][4]{7} = 25; $arr[0][5]{8} = 31; first sort on values in the hash.. when the values are same reverse sort based on keys... Please tell me how to do this.. Thank you

    Read the article

  • HTML5 : Microsoft sort deux modules Websocket et IndexedDB pour IE9 et tester ces standards "encore instables"

    HTML5 : Microsoft propose des modules pour Websocket et IndexedDB Installables sur la bêta d'Internet Explorer 9 Microsoft vient de lancer un site dédié aux standards HTML5 ouverts, une manière de permettre aux développeurs d'expérimenter des standards qui ne seront pas intégrés à Internet Explorer avant leur finalisation par le W3C. Une approche qui se veut plus prudente et pragmatique que celles de ces concurrents, qui n'hésitent pas, eux, à implémenter - au moins partiellement - des standards en gestation dans les versions grand public de leurs navigateurs. Appelé HTML5 Labs, ce nouveau site propose, pour ses débuts, deux modules. Le premier est le...

    Read the article

  • Oracle sort Oracle Application Express 4.2, son outil de développement rapide intégré à Oracle Database

    Oracle Application Express, l'outil de développement rapide d'Oracle est désormais disponible en version 4.2. Cet outil, intégré à Oracle Database sans coût supplémentaire, permet de développer des applications Web exploitant les données d'une base Oracle. Cette mise à jour est très centrée vers le mobile et apporte un certain nombre de nouveautés pour le développement d'applications mobiles avec APEX. Notons en particulier :Le rendu des applications qui s'adaptent pour proposer une interface adaptée au terminal mobile utilisé L'utilisation de jQuery Mobile qui permet la compatibilité sur la majorité des terminaux sans modification La possibilité de créer des graphiques en HTML5 pour les terminaux ne disposant pas de Flash L'utilisat...

    Read the article

  • ZeroTurnaround sort la version 3.1 de son outil de productivité Java JRebel et améliore son support

    Outre des corrections d'anomalies, JRebel supporte désormais les changements dans le mapping Object Relationnel pour les implémentations de JPA que sont Hibernate et OpenJPA. Toplink/EclipseLink est également pris en charge mais c'est encore expérimental (à activer si vous souhaitez tester). Au rayon de l'accès aux données, il y a également désormais une prise en charge des modifications de sql maps pour iBatis.

    Read the article

  • Merge sort. ArrayIndexOutOfBoundsException [migrated]

    - by user94892
    When I execute the program I am getting an error as stated below the program. Please help me figure out the problem.. import java.util.*; class Mergesort { public static void main(String args[]) { Scanner in= new Scanner(System.in); System.out.println("Enter the number of elements"); int n= in.nextInt(); int a[]= new int[n]; System.out.println("Enter the contents"); for(int i=0; i<n; i++) { a[i]=in.nextInt(); } a = mergesort(a,n); for(int i=0; i<n; i++) { System.out.println(a[i]); } } public static int[] mergesort(int[] x, int z) { if(z==1) { return x; } int b[]=new int[z/2]; int c[]=new int[z-z/2]; int i,j,k; for(int p=0;p<z/2; p++) { b[p]= x[p]; c[p]= x[p+z/2]; } c[z-z/2-1]= x[z-1]; b= mergesort(b,z/2); c= mergesort(c,z-z/2); for(i=0,j=0,k=0; k<z; k++) { if(b[i]<=c[j]) { x[k]=b[i]; i++; } else if( b[i]>c[j]) { x[k]=c[j]; j++; } else if(i== z/2) { x[k]= c[j]; j++; } else if(j == z-z/2) { x[k]= b[i]; i++; } } return x; } } Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1 at Mergesort.mergesort(Mergesort.java:41) at Mergesort.mergesort(Mergesort.java:36) at Mergesort.main(Mergesort.java:16)

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >