473,406 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Array advice

I am converting a VB6 App.

In the VB6 app, I have a Type structure of about 30 elements (mixture of
booleans, integers, strings and some doubles), in an array of say 20 to
100+ records.

The size of the array doesn't change that frequently, so the speed of
inserting and removing records is not that important. However, the
speed of finding, and read/writing of the elements is very import.
Needs to be thread safe too.

Am I best sticking with setting up a Structure, and attaching it to an
array, manually sizing it, and recursively searching though it, or is
there a better alternative?

Thanks,
Stuart.

Nov 20 '05 #1
1 1055
Create a sorted secondary array with your most searched item. Then you can
use a binary seach to find what you want quicky.

Example;
'-- Your struct array
mystruct(0).name="Mark"
mystruct(0).Id = 152437

mystruct(1).name="Bob"
mystruct(1).Id = 23437

mystruct(2).name="Chuck"
mystruct(2).Id = 37674

mystruct(3).name="Mr Cool"
mystruct(3).Id = 17222

mystruct(4).name="Terry"
mystruct(4).Id = 7865

mystruct(5).name="Dufuss"
mystruct(5).Id = 67543

'-- Sorted Secondary Array:

Dim sortedArray(5) as Integer

'-- These are sorted by name
sortedArray(0) = 1 '-- Bob
sortedArray(1)=2 '-- Chuck
sortedArray(2)=5 '-- Dufuss
sortedArray(3)=0 '-- Mark
sortedArray(4)=3 '-- Mr Cool
sortedArray(5)=4 '-- Terry

Then use a binary search on this array and not you struct array. You can
also create another sorted array for the id's if you wish.


"Stuart" <st****@stu.org.uk> wrote in message
news:bp*************@ID-17980.news.uni-berlin.de...
I am converting a VB6 App.

In the VB6 app, I have a Type structure of about 30 elements (mixture of
booleans, integers, strings and some doubles), in an array of say 20 to
100+ records.

The size of the array doesn't change that frequently, so the speed of
inserting and removing records is not that important. However, the
speed of finding, and read/writing of the elements is very import.
Needs to be thread safe too.

Am I best sticking with setting up a Structure, and attaching it to an
array, manually sizing it, and recursively searching though it, or is
there a better alternative?

Thanks,
Stuart.

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: csx | last post by:
Hi all, I have the following code, which at the moment is a vector of arrays. But unfortunately, it doesnt do what I want. Basically, here is an example in Java that I want to work in C++. var...
2
by: ip4ram | last post by:
I used to work with C and have a set of libraries which allocate multi-dimensional arrays(2 and 3) with single malloc call. data_type **myarray =...
5
by: Denis Perelyubskiy | last post by:
Hello, I need to make an array of elements accross forms. My javascript skills, as evident from this question, are rather rudimentary. I tried to make an associative array and index it with...
8
by: eft0 | last post by:
Hi there, the question: I have this array: var Thumbnails = new Array(); Thumbnails = new Array('1', 'listing_34.jpg', 'Home View'); Thumbnails = new Array('2', 'sexy2.jpg', 'Sexy');...
8
by: JS | last post by:
I am trying to add an element to an array like this: var ty = ; zz = "ty"; var ab = null; zz+=""; ab = eval(zz); document.write(ab.length);
7
by: Oleg Konovalov | last post by:
Hi, I am trying to pass a bunch of checked checkboxes (Javascript array) from page1 to the Java action class on subsequent web page (page2). (on page 1 I have a bunch of DB rows with a checkbox,...
5
by: WesIdell | last post by:
Hi All: I need some advice regarding a problem that I'm experiencing. I'm using a group of TextBox controls in the .aspx page and am using a function in the .cs code to perform some actions with...
20
by: Gustaf | last post by:
This is two questions in one really. First, I wonder how to convert the values in a Dictionary to an array. Here's the dictionary: private Dictionary<Uri, Schemaschemas = new Dictionary<Uri,...
272
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
7
by: alternative451 | last post by:
Hi, I have just one question : how to know the size of an array, i have un little program, i use first static, ant i can use sizeof() to know the size, but when i put it as paremeter in the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.