Login Password

snippets

Last 10 category snippets

0
favorites
0
comments
Avatar Image

Iterate through hashmap

This loop iterates through a hashmap. very simple. ...
posted by Christopher Krier 11 months, 1 week ago
0
favorites
0
comments
Avatar Image

Minecraft .txt from URL reader.

Title says all! ...
posted by 1 year, 4 months ago
0
favorites
0
comments
Avatar Image

Android Wheel component

Android Wheel component ...
posted by Ilya Bahdanouski 2 years ago
0
favorites
2
comments
Avatar Image

Counts the frequency of a word in a file.

Reads a file from the command line, asks the user to input a word. Counts the frequency of the word in the defined file. (just part of an assignment in college.) ...
posted by Ciaran McNally 2 years, 6 months ago
0
favorites
1
comment
Avatar Image

Super

To simplify ...
posted by Codie 2 years, 8 months ago
0
favorites
4
comments
Avatar Image

Super fast sort algorithm

How my algorithm works (collapse sort), is to think how human normally arrange object. Lets say we have: 3, 8, 5, 9 ,10, 2, 8, 6, 1, 7 First you find the highest value in the array which is 10 Second you create integer array the length of highest value you found This then give us a list of index for the data to be store So far the only comparison we done is finding high number Now we loop all data and place it in the new array 3, 8, 5, 9 ,10, 2, 8, 6, 1, 7 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 _ | 1 | 1 | 1 | _ | 1 | 1 | 1 | 2 | 1 | 1 If you notice Array[8] has value of 2 because there is a repeat After all arrange number have been store in a list we can do a loop to place all those data back in array As you see the is no comparison to slow the process down 1 | 2 | 3 | 5 | 6 | 7 | 8 | 8 | 9 | 10 If this sort algorithm has already been done i am going to be well gutted because so far i know that none of the sort works like my one. I only know 2 disadvantages to this algorithm is that: 1. If value in array is really big then the sort will slow down due unnecessary looping time 2. No matter what is the data is already sorted the time different from mostly ordered data and un-ordered data is the same So far this could be the best sorting algorithm because is faster than any other tested sort Here is my results: For 300000 elements, the times are: Type: Bubble Sort time: 6:42:875 Type: Insertion Sort time: 1:55:843 Type: Selection Sort time: 3:29:032 Type: Heap Sort time: 0:00:125 Type: Quicksort time: 0:00:046 Type: Collapse Sort time: 0:00:016 ...
posted by T Chai 3 years ago
0
favorites
1
comment
Avatar Image

Using JTree

There is only one way to use correctly a JTree but many ways to do it incorrectly. The basic mistake for a very beginner is to add a node with the 'add()' method. WRONG! First use DefaultMutableTreeNode and DefaultMutableTreeModel, don;t use an interface or superclass, you will loose to much time. Second, add a node to the model, see the snipet. ...
posted by Patrice Secheresse 3 years, 1 month ago
bettercodes.org is released as free software without warranties under GNU Affero GPL v3