C# - Speeding Up An Algorithm That Find Patterns In A Growing Collection - Code Review Beta - Stack Exchange?

Jun 25, 2012

I want to find a way to speed up this code.if you look at the condition of If calculated Then in the code below, this is what slowing down the code.While the code provided seem fast with Const initBit = 4 try it with something over 12.

I want to be able to use this code (with calculated param as True) with initBit of 20 or more.

Beware that 20 or more might require a gig or more of ram and/or compiled as x64.

C# code (converted with an online tool from VB.NET):

[Code]...

View 2 Replies


ADVERTISEMENT

Request For Peer-Review KeyedBindingList (Of TKey / T) Generic Collection Concept

Aug 18, 2011

There are a lot of different generic collections available, so the wisdom in creating a new one may be questionable right from the start.However, I often find myself wanting the same features from my custom generic lists, but cannot quite find all of those features in an existing object; namely, I would like to have a generic collection which works like a List or Dictionary (much like the System.Collections. ObjectModel. Keyed Collection(Of TKey, TValue)), but also works like a BindingSource does when it is bound to an ADO object (that is, it supports full sorting and filtering as well as currency).A feature I almost never need however, is transactional adds (the BindingSource's ability to 'cancel add-new').Again, with so many existing collections out there, I should take a moment to go over the reasons why none of them quite meet my needs.There is the System. ComponentModel. BindingList(Of T) which would provide some of the functionality of a BindingSource, but has strict requirements about the type {T} implementing IComparable in order to support sorting, and does not provide filtering (it is not an IBindingListView).It also only maintains a base item list by index, so does not provide keyed access.We could use simple databinding with a custom list inheriting from System.Collections. ObjectModel. Keyed Collection(Of TKey, TValue) bound to a BindingSource, but again TValue would have to implement IComparable to support sorting and we would still not have filter support.So to get all the features I was after, I decided that the best thing would be to create a new generic collection object which implemented IList, IDictionary, IBindingList, and IBindingListView (along with a few others) and would be capable of serving as a simple list, or as a binding source while providing full sorting and filtering over any newable object type.

To that end, I've created the KeyedObjectModel which contains the KeyedBindingList(Of TKey, T) generic collection/binding source. This collection can be used as a typical list, or as a binding source (you do not need an additional BindingSource component between the collection and UI controls, although you could certainly have one).Various constructors are provided in order to initialize an instance of the collection as either an enhanced list-dictionary, or as a complete BindingSource.Any object that has a public constructor which takes no arguments can be used at type {T}, providing that the object has a property of type {TKey} which will contain unique values for each entity in a given collection.If the object implements System.ComponentModel.NotifyPropertyChanged then the collection will also bubble up property changes on the current item to the collection's CurrentItemChanged event.An implementation of IComparable on type {T} is irrelevant because sorting and filtering are performed on the property values of {T} based on the type of the specified property.The current design of KeyedBindingList(Of TKey, T) is in an 'alpha' stage.The class is mostly complete from a feature implementation standpoint, however, the code has not yet been optimized and the base collections of values, keys, and view are being maintianed in generic lists of their own, rather than raw arrays.However, even without performance tuning, the collection appears to be performing quite well, up to a few thousand entries, given the amount of flexibility and funcitonality it provides.At this stage, I would really love to get some peers to try using the compiled DLL and beat up the collection a bit.Once the code has been proven and optimized, I will publish it as an example.It is a fairly complex class though (currently made up of eleven or so partial classes) so I don't really want to post the code until it has been optimized. [code]

View 4 Replies

.Net Stack Collection Efficiency?

Apr 15, 2009

I've started using .Net's stack collection. The basic features I guess are the "pop" and "push", where you add or take off the top element of the stack (if you are referencing other elements in the stack then another collection type is probably better).[URL]..it appears that the Stack collection (like other collections) is basically an array with some window dressing (so you actually can see other elements). As far as I can tell, "popping" and "pushing" is changing the first element of the array. Shouldn't instead the final element be the "top" of the stack and be the one that is changed? Otherwise the program has to reindex all the other elements in the array every time a pop or push is made. This seems very inefficient. But this is what Microsoft's description appears to be saying what is happening.

View 10 Replies

Speeding Up Code That Copies Database Structure To XML

Aug 23, 2010

I have a database structure filled with data that I'm trying to write out to an XML file. Here's a taste of the way the VB code is structured:[code]I can't see or report any progress, because the processing is all tied to one giant LINQ query. Even if I can't make it any faster, I'd like to know how much longer I have to wait. My first version of this code had For loops instead of queries, so I could display progress, but it took a loot longer.Obviously I'd like to speed this up considerably. It seems like there should be a simpler way to convert the data to an XML file, especially since the database structure was created from the XSD in the first place.

View 1 Replies

Database Access Pattern Code Review?

Nov 6, 2010

Anyone here kind enough to give me a code review on the following pattern that I have used for database access? I have provided one of the simpler datalayers to show the basic idea.In particular I am starting to question if using shared methods was a good idea and what problems may arise from that? Will this implementation fail in a threaded environment like ASP.Net?

Public Interface IFillable
Sub Fill(ByVal Datareader As Data.IDataReader)
End Interface

[code].....

View 1 Replies

VS 2008 Code Review (Control Making)

May 7, 2009

I downloaded this code from the web that Wierddemon gave me in my previous thread. This solution contains 2 projects (CurrencyControlTest and CurrencyTextBox) There are some things that I don't understand:

1. What's the type of form1.vb and program.vb in the CurrencyControlTest Project? Are they classes, or windows Forms or module?

2. This is the code in Program.vb

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic

[CODE]...

What's the effect of <STAThread> code?

3. What is exactly the "Namespace" doing in this code? because when I removed the namespace, An error indicating that Form1 is not declared appeared. What is namespace? what does it do? Can anyone give sample code to emphasize the function and how and when to use the keyword "Namespace"?

4. This is code for Form1 in CurrencyControlTest Project

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic

[CODE]...

What's with the "public partial class Form1"? what does "partial" do? When i right-clicked on the InitializeComponent(), A portion of code appeared suddenly with the header #Region. What is this? and when re-open the Form1 in "View Code" mode, they're gone.

View 7 Replies

Asp.net - (3 Tierish) Database Access Pattern Code Review?

Jan 19, 2011

Anyone here kind enough to give me a code review on the following pattern that I have used for database access? I have provided one of the simpler datalayers to show the basic idea.In particular I am starting to question if using shared methods was a good idea and what problems may arise from that? Will this implementation fail in a threaded environment like ASP.Net?

[Code]...

View 1 Replies

Code Review: ADO.NET Data Access Utility Class (VB)?

Mar 6, 2009

When I started at my current employer I inherited a project from a previous developer and in that project was a data access utility class that tries to simplify a lot of the code involved in making calls and retrieving data back from the database. Over time it has been modified to add more overloaded forms of functions, and now I am looking at possible suggestions from the StackOverflow community.What do you think should be added? Removed?odified?Note:It would be nice if this class could remain compatible to VB.NET in the .NET 2.0 framework. We are also developing in 3.5, but I would like to have something that is generally going to work across most frameworks (so no LINQ, etc.) Also, please refrain from unnecessary answers that consist of nothing but "Use nHibernate" or other tools.

My class:
Public Class DataAccess
Public Shared Function ReturnScalar(ByVal CmdStr As String) As String

[code].....

View 2 Replies

.net - Code Review: Determining Whether A Folder Exists, Given The Full File Path?

Nov 30, 2009

With a function being passed a full path to a file, such as C:someFolderanotherFoldersomeXML.xml, determine whether the folder exists. Is there a smarter/better/more elegant way of doing this? Here is my implementation:

[code].....

View 2 Replies

Error Created When Opening Beta 1 File In Beta 2

Apr 19, 2005

I have save the file in beta 1 and when i upgrade to beta 2?Error 1 Type 'System.Windows.Forms.WindowsFormsApplicationBase' is not defined. Error 2 'AuthenticationMode' is not a member of 'Forms'. Error 3'ShutdownMode' is not a member of 'Forms'.Option Strict On[cod]e...

View 6 Replies

How To Find Index Of Item In A Stack

May 26, 2009

I am using the stack class to store a collection of lines. <code>Dim myStack As New Stack(Of Line)</code> I want to find out what the index is of one of the lines that are in the collection and I'm not sure how to do this. i tried to use array.indexOf:

[Code]...

View 7 Replies

Find And Replace Algorithm?

Sep 9, 2010

I have some text files that contain

<img width="100" or

<img width="1400" or....

How could i replace all above with the following, since the image width is not static?

<img width="200"

View 1 Replies

Find Exception Stack Trace Outside Of Visual Studio?

Mar 11, 2010

I have my .net app running on my home machine, and at one point it threw an exception.Problem is, Windows doesn't tell me what the exception is, just says that it stopped responding and closed it.I want to find the exception and stack trace so I can debug it, since I can't to reproduce the problem inside visual studio.The machine is running Windows 7 x64. I found in the event viewer some minor information:

Problem signature:
P1: server info.exe
P2: 1.4.0.0

[code].....

So based on that I can see there was a null reference. I remember way back when I was on XP, when the application crashed it would show the whole exception stack. Can I find that information somewhere?

View 3 Replies

IDE :: Slow Code Editing In VS 2010 Beta 1?

Jul 1, 2009

I've tried using the VS 2010 beta to edit some real projects, and it is next to unusable due to performance issues. The cpu is more or less constantly at 100%, and most often the code editor uses around 10 seconds to respond to any text input. If I introduce a couple of compile errors things get even worse. Are there some drastical performance improvements that are planned in the VB editor before release, or are there special things that might trigger this?

View 22 Replies

Algorithm To Find Word On Boggle Board?

Aug 6, 2009

What I want it to do is, as I'm typing the word, that it highlights it on the board using the button(x,y).doclick sub which highlights it. Right now my implementation finds the first letter, then keeps trying each letter until it meets the 8 corner condition (ie it is neighbored to the last one) but this does not always work. If there are say 2 "G"'s on the board and I want the bottom one, this will not work. Can somebody give me an example of psuedocode

View 1 Replies

VS 2010 Algorithm To Find Pattern In Data

Jan 17, 2012

Has anyone ever used VB to analyze data to find patterns? I would like to analyze several hundred sequential data points to look for a fairly uniform "up-down" pattern, very similar to a square wave.

View 3 Replies

Interface And Graphics :: Algorithm To Find Identical Adjacent Pixels In Bitmap?

Aug 12, 2011

I need to write a code to find identical adjacent pixels in a bitmap image. It should work as the 'magical wand' in Photoshop.My images are always black and white (white background with car parts drawed in black). Given the x,y coordinate for a single black pixel in the whole image, the code should find (and paint with another color, say red) all other black pixels that are linked to that one, and so on, until all linked black points will be painted in red.This way, suppose that I have an image with 4 car parts drawed, then if I give the x,y coordinate of a black pixel, just THAT part to whose the black pixel belongs to should be painted in red. All other parts will remain black. Does it make sense?At the end, there are two pictures (before and after) to help understanding what I need to do to the images.I tried a simple 8-pixel adjacent approach for every pixel (starting on initial coordinate) but it turns out into a very stupid and endless looping algorhitm.

Code:
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

[code]....

View 4 Replies

CODE - Get The Stack Overflow Error ?

Feb 12, 2012

could you tell me, why I get the stack overflow error on this code?

Dim ev As Double = datum.Year * 365 * 24 * 60 * 60
Dim honap As Double = datum.Month * 30 * 24 * 60 * 60
Dim nap As Double = datum.Day * 24 * 60 * 60
Dim masodpercek As Double = ev + honap + nap

The double datatype should be enough.

View 5 Replies

.net - Exchange Code For Token Facebook-c#-sdk?

May 21, 2012

I am using The Facebook-C#-Sdk v5.0.3 to create a non-canvas webforms app in vb.net and i am having trouble exchanging the returned facebook code for the access_token. Does anyone have an example (C# or vb.net) that I can look at

View 1 Replies

Exchange Public Folders - ASP.NET Dream.In.Code?

Mar 16, 2010

I have an internal ASP.NET / VB.NET CRM page that I would like to build additional functionality into.Currently we still use "Public Folders" in Exchange to store contact information for our clients.

What I would like to do is be able to connect to the Public Folders on Exchange through VB.Net in order to add new contacts or edit current ones.I would prefer to NOT have Outlook installed on the web server - (I say this because I tried working with Excel using COM and it was crap - ended up using Gembox.spreadsheet for all of my Excel needs).

View 3 Replies

Getting Code Of Antnet Algorithm

May 8, 2012

i am working on project of using ant colony optimization and espcially on antnet algorithm but i have many problems in programming of this algorithm, and since i dont perfer using simulation for that purpose.

View 4 Replies

C# - Creating A Public Folder On An Exchange Server From Code Behind?

Feb 9, 2012

I have to create a project management application in VB.Net Framework 4 which should create a client folder in a public folder in Exchange server.

I think the only way to create a public folder is through the management console. Is there a way to connect to the Exchange server and execute the creation command file from the code but I do not know how.

View 1 Replies

Vb2008 Code To Send Exchange Server Emails?

Nov 2, 2009

I'm trying to do what it says in the title. I don't even need to send a message body, just the subject will do. The full code with imports and references would be a

View 2 Replies

Code - Add The Elements To The Stack With Keeping Track Of Adding And Deleting

Feb 15, 2012

I am trying (Push)add data into my stack (length of five) and (Pop)delete from the end of my stack.

I need to know how can:

- Add the elements to the stack with keeping track of adding and deleting from it (adding an element will increment until 5 and deleting would decrement until the stack is empty).

Private Sub Button1Push_Click(sender As System.Object, e As System.EventArgs) Handles Button1Push.Click
Dim Stack(4) As String

[CODE]....

View 4 Replies

.net - Beam Search Algorithm - Pseudo-code?

Jul 17, 2011

I want to write a simple beam search algorithm to solve a maze (like a tree, and the output must be the shortest path).So, if anyone have tried to write a beam search algorithm before, preferably in VB.NET language, it would be great if you can share it in a pseudo-code format.

Because, I have no idea on how to write the algorithm. I have tried to Google it, but I understand nothing.I found this source though (which I don't understand at all XD) [URL]..So, back to my question, how to write a beam search algorithm? Preferably, in VB.NET language and pseudo-code will be enough for me (an actual example code will be great though

View 1 Replies

Develop A COMPLETE Algorithm Using Pseudo Code

Jun 6, 2011

WHERE IS MY Problem. Develop a COMPLETE algorithm using pseudo code to solve the following problem: Your network contains hundreds of workstations. The primary local drive (C on each of those workstations may contain many folders immediately under the root folder. You need to search each of the folders under the root folder on each of the workstations to see if the file nasty.bug exists. You need to do two things with respect to this file. First, count the number of times this file is actually found and, after all the workstations have been scanned, display a message indicating the total number of occurrences of this file across your network. Second, whenever the file is found, it should be deleted.

View 1 Replies

Homework - .net Network Graph Code/algorithm?

Dec 8, 2010

For a school project we need to visualise a computer network graph. The number of computers with specific properties are read from an XML file, and then a graph should be created. Ad random computers are added and removed.Is there any open source project or algorithm that could help us visualising this in VB.net? Or would you suggest us to switch to java.

Update: We eventually switched java and used the Jung libraries because this was easier for us to understand and implement.

View 1 Replies

Write A Code About Counting Inversion Algorithm

Jun 17, 2009

I am trying to write a code about counting inversion algorithm.I finished the code but the result was wrong..I dont no where is the problem but I think it is in the count-merg function [code]

View 2 Replies

Error: No Symbols Are Loaded For Any Call Stack Frame. The Source Code Cannot Be Displayed

Jul 21, 2011

I have just a form in my VB.Net project and even when I try debugging that - there is nothing going on besides the form being loaded - I get the error: No symbols are loaded for any call stack frame. The source code cannot be displayed.

View 3 Replies

Piece Of Code To Only Execute Scoring Algorithm At Certain Times

Dec 15, 2011

I have a standard scoring algorithm but I need to help on a piece of code to only execute the scoring algorithm at certain times.I want it to be triggered by dates, but the problem arises if the program is used after 2 (or more) dates have passed, the first date will not be added as the second date is the newest and therefore the one that triggers the scoring algorithm. - The scoring algorithm gets the scores for that week, which are stored in a text file.

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved