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 8732543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:27:32+00:00 2026-06-13T09:27:32+00:00

I have written an Android app. It is a simple version of the old

  • 0

I have written an Android app. It is a simple version of the old board game Connect 4. Currently my “Board” object holds the counters which have been places on the board. There are 2 players to this game.

The Board class comprises of 7 ArrayList objects, each one represents a column on the board.(the board is 7 across x 6 upwards). So for example when the red player clicks on the third column on the screen I call

boardObj.addCounter("red", column);

and inside the board object in the addCounter() function it does something like

column3.add(playerColor);

so the ArrayList column3 gets another item added and so forth.

My question is – is there a better data structure I can use as opposed to using 7 ArrayLists? I noticed that the function which checks whether there is a win, which is called after a counter is added to the board, is becoming quite an expensive function in terms of CPU. What structure would allow me to get and set the data and run my checkwin() algorithm with the best performance?

  • 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-06-13T09:27:32+00:00Added an answer on June 13, 2026 at 9:27 am

    You have a 7×6 board, and you need to test for elements on the same row, column or diagonal.

    A 2-dimensional array is the most obvious choice. I would use that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written an android app which listens to the phone signal strength using
I have written a simple android app and it runs in the emulator. Now
I have written a simple database driven app in C# which uses a 2
I have written a simple app for Android and when I first created the
I have written a simple app which atm just pops up a toast message
I have written a simple WebView app and tested it on android 2.3. When
have written this little class, which generates a UUID every time an object of
Newbie question. After I have written the Android App (easy part) I need to
I have written an Android app (target 3.2) using Eclipse 3.7, I tried to
In an android app, I have written code to get geo data through GPS

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.