Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 992069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:12:24+00:00 2026-05-16T06:12:24+00:00

I am finishing up a program that does a large number of calculations and

  • 0

I am finishing up a program that does a large number of calculations and am trying to optimize the innermost loop.

The calculation I am currently looking at iterates over a large number of pairs of words and makes a table of the counts of corresponding pairs of characters. For example, one pair of words might be:

voice
louse

and the character pairs would then be (v,l), (o,o), (i,u), (c,s), and (e,e), and these pairs would all then have a count of 1. If the combination (v,l) is ever encountered again in another word, it would increment that count to two.

What data structure should I use for highest performance? Given the two characters, I need to retrieve the count for that pair. Currently I am using a nested hash table whose declaration looks like:

Dim data As New Dictionary(of String, Dictionary(of String, Integer))

Using this data structure, the program must hash two strings for every integer it retrieves. For every character pair, it must first check to see if the pair is in the hash table, and if not add it, requiring two more hashes. I have also considered a one level hash table with the key being the two characters concatenated together, so key = “vl” and value = 1, but I have read that string concatenation is relatively slow in VB.

So then, my questions are:

How speedy are the Dictionaries in VB? Would four hashes be quicker than one hash and a string concatenation (two level vs one level hash table)?

Can you think of a better structure to store this kind of data that allows fast additions and retrieval?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:12:24+00:00Added an answer on May 16, 2026 at 6:12 am

    One option is to use a Dictionary(Of Integer, Integer). You can convert from any .NET Unicode character to an unsigned 16 bit integer, as they’re UTF-16 code units.

    You can then combine two unsigned 16 bit integers into a 32 bit integer very easily. Alternatively, you can just convert each code unit into a 32 bit unsigned integer to start with, and shift and combine in the same way 🙂

    In C# I’d just use:

    int combination = (((int) char1) << 16) | ((int) char2);
    

    EDIT: According to jeroenh’s comment, the VB equivalent is:

    Dim combination As Integer = (AscW(char1) << 16) Or AscW(char2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently finishing up a php program that backs up multiple Google Calendars which
I am currently finishing up on a program that is suppose to parse a
I've been asked (as part of homework) to design a Java program that does
I am finishing off a C# ASP.NET program that allows the user to build
I'm trying to create a program that grabs data from a website x amount
i'm trying to create a simple program that will upload a few files for
C++11 introduces a new way of finishing program execution— std::quick_exit . Quoting the N3242
I'm finishing up a website with code partially done by a freelancer that didn't
I'm finishing up the Core Data tutorial, and it suggests trying to convert to
I need help finishing this statement. It is frustrating that two of the PHP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.