I am just starting a new WPF project using MVVM as a general guideline. The application will have a ribbon; when you switch between tabs, there will be different buttons that spawn dockable windows in the content pane below the ribbon. This part is done. Now, each of those windows contains a different user control. These user controls all can interact with data used in the other user controls. There is going to be somewhere between 20 - 30 different user controls. My question: Is it more efficient for me to create one single static instance of these user controls …

Member Avatar
Member Avatar
+0 forum 1

I have an array of objects that I need to iterate through in order to get three items. The parts of the object important in this context are: value and type. I need to find the first three items from the array that have the greatest value sum and are of the same type. Right now I've just used three "for" statements to iterate through the array and compare all the combinations of three items. However this is extremely inefficient and it seems like there should be a better solution. I thought sorting the array in descending order would give …

Member Avatar
Member Avatar
+0 forum 6

I have this issorted code to sort elements of an array. It's very slow as it is right now due to a lot of memory access, number of branch instructions per iteration of the poorly written loops, and unorganized instruction/register usage causing dependencies between instructions. I'm not sure on how to go about improving my code to be faster and efficient. I need a nudge in the right direction as I'm new to assembly. .globl issorted .align 4, 0x90 issorted: movl $1, %eax .align 4, 0x90 LBB1_1: cmpq %rsi, %rax jge LBB1_4 movq (%rdi,%rax,8), %rcx leaq 1(%rax), %rdx cmpq %rcx, …

Member Avatar
Member Avatar
+0 forum 3

I wrote the following code to test which is faster: performing a multiplication and division many times, or accessing the results in a vector via iterators(perform the calculations ahead of time), or hard coding the results of those calculations into the program. I actually expected storing the results in the vector to be faster than performing the calculations, but on my system I get the following relation for the times to complete each corresponding function: Hard Coded Values < 5 * (On the fly calculations) < 50 * ( Vector Stored Values) So my question is this: Am I stuck …

Member Avatar
Member Avatar
+0 forum 11

I'm doing some research to determine the most efficient way to copy files. I've got 3 candidate functions: #1 [CODE=python] # uses generator to load segments to memory def copy(src, dst, iteration=1000): for x in xrange(iteration): def _write(filesrc, filedst): filegen = iter(lambda: filesrc.read(16384),"") try: while True: filedst.write(filegen.next()) except StopIteration: pass with open(src, 'rb') as fsrc: with open(dst, 'wb') as fdst: _write(fsrc, fdst)[/CODE] #2 [CODE=python] # loads entire file to memory def copy2(src, dst, iteration=1000): for x in xrange(iteration): with open(src, 'rb') as fsrc: with open(dst, 'wb') as fdst: fdst.write(fsrc.read())[/CODE] #3 [CODE=python] def copy3(src, dst, iteration=1000): for x in xrange(iteration): with …

Member Avatar
Member Avatar
+0 forum 4

Basically, i've been told to initialise a grid into the "canvas" section of this program i've made, I need to make a fine grid that stretches across the whole canvas horizontally and vertically, 10 x 10 pixels apart example of the code i'm editing to do this below... [CODE] class Canvas extends JPanel { // Called every time there is a change in the canvas contents. public void paintComponent(Graphics g) { super.paintComponent(g); draw(g); g.setColor(new Color(0.8F, 0.8F, 0.8F)); g.drawLine(10, 800, 10, 10); g.drawLine(20,800, 20, 10); g.drawLine(30, 800, 30, 10); g.drawLine(40,800, 40, 10); g.drawLine(50, 800, 50, 10); g.drawLine(60,800, 60, 10); g.drawLine(70, 800, …

Member Avatar
Member Avatar
+0 forum 7

""" Write a function to convert temperature from Celsius to Fahrenheit scale. oC to oF Conversion: Multipy by 9, then divide by 5, then add 32. Examples >>> Cel2Fah(28.0) '82.40' >>> Cel2Fah(0.00) '32.00' """ so it says, but i couldn't think of an a way to do so efficiently. But none the less, i felt i should try it and then look up a better way after the code i wrote is as follows; [CODE] def Cel2Fah(temp): Fah = temp * 9 / 5 + 32 Fah = float(Fah) Fah_string = str(Fah) a = Fah_string.split('.') b = a[1][0:2] if len(b) …

Member Avatar
Member Avatar
+0 forum 2

So basically I am done with my project, I've passed to our instructor already, and I've achieved an above average grade, but one thing though I am still not satisfied, can someone check this code out for me? give me few tips? ? or tricks about this? here's my code :) rate it and help me improve it (I want to improve it so that I could be a good java Programmer, and again I alraedy passed this project) [CODE]import java.util.Random; public class Game { Player player = new Player(); Banker banker = new Banker(); private int a = 0; …

Member Avatar
Member Avatar
+0 forum 9

The below bit of code is running very very slowly. I cant see why this should be but there seems to be almost a second delay when I'm using f8 to run through the code bit by bit when I get to the end if...any clues? [code] Sub firstResponse() Dim rCell As Range For Each rCell In Range("S2:S462") If rCell.Offset(0, 3).Value = 1 Then rCell.Value = "CLICK" ElseIf rCell.Offset(0, 1).Value = 1 Then rCell.Value = "OPEN" ElseIf rCell.Offset(0, 2).Value = 1 Then rCell.Value = "BOUNCE" ElseIf rCell.Offset(0, 1).Value = "" Then rCell.Value = "" Else: rCell.Value = "NONE" End If …

Member Avatar
Member Avatar
+0 forum 8

Can this code of mine be more efficient? [CODE]import java.util.Scanner; public class Game { public static void main(String args[]){ boolean gamestatus = true; //Boolean to control the whole game double total = 0; //Temporary variable for storing the average Banker banker = new Banker(); //creation of the object banker; int cases = 26; int turn = 0; //counter variable to count the number of turns Scanner input = new Scanner( System.in ); //creation of the scanner object Briefcase briefcase[] = new Briefcase[27]; //an array of briefcases double amounts[] = {0,0.01,0.5,1,5,10,11,14,20,300,600,150, 13,14,15,16,17,18,19,20,21,22,23,24,25,26,28}; //The Amounts to be inserted in to the cases …

Member Avatar
Member Avatar
+0 forum 4

I am making a page which pulls from the user's browser their preferred language, via the Request.UserLanguages....which returns a two letter code (ex. "en") or detailed code (ex. "en-GB"). I basically get the string of user languages (they are in order of preference) and store them in a string array. Then I use a loop to check if the language code in the first position of the string array is any of the codes for a certain language (another string array hard coded in). Is there a better way to do this? I'm noticing increased load time and am worried …

Member Avatar
Member Avatar
+0 forum 2

Hi everyone, I have created a random text generator -ok, not so random, works with certain parameters- and at times it runs slowly. I looked up on the internet about speeding tricks and applied some of them that looked concurrent with my code piece. The code however, is still slow and I want to optimize it as much as possible in order to make it work on even bigger data. -Currently, 18 books from the Gutenberg corpus are processed by my code and I am trying to get one sentence per every 3-4 minutes but most of the time, the …

Member Avatar
Member Avatar
+0 forum 1

Hello everyone, I have created my own random text generator with a custom method, no Markov chains included, and now I would like to try it on a different text corpus that is larger from that of NLTK's and I wanted to know which Data structure should I use in order to make the code work faster since additional text files will surely make the code a painstaking procedure to execute. My algorithm is as follows: 1- Enter the trigger sentence -only once, at the beginning of the program- 2- Get the longest word in the trigger sentence 3- Find …

Member Avatar
Member Avatar
+0 forum 2

I found [URL="http://www.daniweb.com/software-development/cpp/threads/358674"]this assignment[/URL] on C++ forum as was browsing to see little where I am in my mostly C little C++ thrown in understanding of C++ and if I should try to increase my knowledge in that language. I could not believe my eyes! The OP is completely lost what to do and what approach to take and do not finish in time. Ok, we must consider that I have read this post for main points before but I do one experiment. [LIST=1] [*]I paste the description on this post and log the time [*]I write the function for …

Member Avatar
Member Avatar
+0 forum 6

The End.