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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:25:41+00:00 2026-06-13T07:25:41+00:00

For example I can have something like so, A B ba bb C Ca

  • 0

For example I can have something like so,

A
B
 ba
 bb
C
 Ca
D

Right Now I have a 2D array,but this isn’t very general, because I would need another dimension if I wanted to extend the maximum sublevel from 2 to 3. Any suggestions?

  • 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-13T07:25:43+00:00Added an answer on June 13, 2026 at 7:25 am

    The Composite Pattern would be an appropriate application here:

    Composite Pattern

    (From wikipedia:) http://en.wikipedia.org/wiki/Composite_pattern

    In your case:

    • Create a base class called “Menu” (This corresponds to the Component part in the above diagram)
    • Create a derived class called “MenuItem” (This corresponds to the Leaf part in the above diagram)
    • Create a derived class called “SubMenu” (This corresponds to the Composite part in the above diagram) SubMenu can contain more Menu’s – which can be more MenuItem’s or SubMenu’s.

    You can achieve desired ordering of menu elements based on their insertion order into a Composite “SubMenu” by implementing a counter with each SubMenu object: each time you call aSubMenu.add(newMenuItemOrSubMenu), aSubMenu should increment its own counter and tag the new item with the ordering number. (Exact detail of the implementation is up to you, you don’t have to use separate counter at all and just use a list or an array)

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

Sidebar

Related Questions

For example can i have something like this: public static void SAMENAME (sameparameter n)
Currently, I have URLs that look like this: http://www.example.com/user/create http://www.example.com/user/edit/1 But now, I have
I have a multidimensional array that looks something like this: ourThing = array( 'id'
How can I delay actions between keypress in jQuery. For example; I have something
I have this simple example I can't seems to get working : MERGE INTO
I have a set of classes something like this: abstract class CollectionAbs implements Iterator
I have a (client/server communication) setup right now like so: 1) Client asks user
I have this right now to use a cookie value if exists otherwise use
Right now I have an x by y array to hold integers that decide
For example can I have class Dog { int legs; Bone chewy; Bone squeeky;

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.