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

  • Home
  • SEARCH
  • 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 8193289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:25:54+00:00 2026-06-07T04:25:54+00:00

i have recently stumbled upon a project(8-puzzle solver using A* alg) in which some

  • 0

i have recently stumbled upon a project(8-puzzle solver using A* alg) in which some codes are weird to me , because i have never seen the likes of it before .

what does this line mean ? what is this ?!

this[StateIndex]

whats this notation ? i cant undersand it at all !
i posted a sample of the class so that you can see it almost all together .
and one more question , is it not wrong to have a class implemented like StateNode? it used only a constructor to initialize its fields , and yet worst, declared them all public ! should he/she not have implemented Propertise for this task?

public enum Direction 
{
    Up = 1, Down = 2, Left = 3, Right = 4, UpUp = 5, DownDown = 6, LeftLeft = 7, RightRight = 8, Stop = 9
}

class StateNode
{
    public int Parent;
    public List<int> Childs;
    public Direction Move;
    public Direction ParentMove;
    public byte[,] State;
    public byte Depth;
    public byte NullRow;
    public byte NullCol;
public StateNode()
{ }
public StateNode(int NewParent, Direction NewMove, Direction ParentMove, byte NewDepth, byte NewNullRow, byte NewNullCol)
{
    this.Parent = NewParent;
    this.State = new byte[5, 5];
    this.Move = NewMove;
    this.ParentMove = ParentMove;
    this.Depth = NewDepth;
    this.NullRow = NewNullRow;
    this.NullCol = NewNullCol;
    this.Childs = new List<int>();
}
}

class StateTree : List<StateNode>
{
    public static long MakedNodes;
    public static long CheckedNodes;
    public static byte MaxDepth;

    public List<int> Successor1(int StateIndex)
    {
        List<int> RetNodes = new List<int>();
        StateNode NewState = new StateNode();

        //Up
    if (this[StateIndex].NullRow + 1 <= 3 && this[StateIndex].ParentMove != Direction.Up)
    {
        NewState = ChangeItemState(this[StateIndex], StateIndex, Direction.Up, Direction.Down, Convert.ToByte(this[StateIndex].Depth + 1), this[StateIndex].NullRow, this[StateIndex].NullCol, Convert.ToByte(this[StateIndex].NullRow + 1), this[StateIndex].NullCol);

        this.Add(NewState);
        RetNodes.Add(this.Count - 1);
        StateTree.MakedNodes++;
        this[StateIndex].Childs.Add(this.Count - 1);
        if (NewState.Depth > StateTree.MaxDepth)
            StateTree.MaxDepth = NewState.Depth;

    }
    //Down
    //Left
    //Right

    return RetNodes;
}
}
  • 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-07T04:25:55+00:00Added an answer on June 7, 2026 at 4:25 am

    this[StateIndex] is using the current class’ indexer property. The indexer property is what allows you to access an element in a collection or list object as if it was an array. For instance:

    List<string> strings = new List<string>();
    strings.Add("Item 1");
    strings.Add("Item 2");
    strings.Add("Item 3");
    string x = strings[0];  // Returns the first item in the list ("Item 1")
    

    When you want to access the indexer property of your own class, however, you have to preface it with the this keyword. You’ll notice that in your example, the StateTree class doesn’t implement an indexer property, so that may be adding to your confusion. The reason it works is because StateTree inherits from List<StateNode> which does implement an indexer property.

    But don’t get confused between classes with indexer properties and arrays. Arrays are a completely different thing, though the syntax is similar. An array is a list of objects which can be accessed by an index. An indexer property is an unnamed property of a single object that acts as an array. So for instance, List<string> has an indexer property, so you can access the items it contains using the same syntax as an array index (as shown in the above example). However, you can still make an array of List<string> objects. So for instance:

    List<string> strings1 = new List<string>();
    strings1.Add("Item 1.1");
    strings1.Add("Item 1.2");
    
    List<string> strings2 = new List<string>();
    strings2.Add("Item 2.1");
    strings2.Add("Item 2.2");
    
    List<string>[] stringsArray = new List<string>[] { strings1, strings2 };
    object result;
    result = stringsArray[0];  // Returns strings1
    result = stringsArray[0][1];  // Returns "Item 1.2"
    result = stringsArray[1][0];  // Returns "Item 2.1"
    

    As far as StateNode goes, there’s nothing technically wrong with it, and it’s not unusual to have a constructor that initializes all the field values, but it’s always better to use properties instead of public fields.

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

Sidebar

Related Questions

I have recently started using PlayN for a hobby project and has now stumbled
I have recently stumbled upon an open source project that I would like to
I have recently stumbled upon a problem with selecting relationship details from a 1
I've recently been developing on the django platform and have stumbled upon Django Forms
Recently, I have stumbled upon the basic understanding about PKI work-in-action process. I have
I have a fair amount of experience using MOQ, while I've recently have stumbled
I have recently tried using the Silverlight NUnit Project template (the one from Jamie
I recently stumbled upon some javascript forums (sadly, link is lost somewhere in the
I recently stumbled upon Etherpad, it's a collaborative writing tool http://code.google.com/p/etherpad/ - main project
I recently stumbled upon Google's MapReduce . I have read the description / docs

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.