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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:06:47+00:00 2026-06-10T23:06:47+00:00

Been banging my head against this for a while. I cant figure out why

  • 0

Been banging my head against this for a while. I cant figure out why the node will not remove from my linked list. I have a linked-list that stores images that I go through and render each one. Problem is they are still being rendered and not removed. Is there any problems with my code? My code seems the same for all other type of linked-lists in javascript.

edit Adding full code since it might be useful:

var object_action_holder = function () {
    this.skill_id =     0;
    this.skill_type =   0;
    this.image_src =    0;
    this.x_pos =        0;
    this.y_pos =        0;
    this.turn_off =     0;
    this._head =        null;
};
object_action_holder.prototype = {

add: function ( skill_id , skill_type , image_src , x_pos , y_pos ) {

    var node = {
        skill_id:skill_id,
        skill_type:skill_type,
        image_src:image_src,
        x_pos:x_pos,
        y_pos:y_pos,
        next:null
    },
    current;

        if (this._head === null) {
            this._head = node;
        } else {
            current = this._head;

            while (current.next) {
                current = current.next;
            }   
            current.next = node;
        }

        this.skill_id = skill_id;
        this.skill_type = skill_type;
        this.image_src = image_src;
        this.x_pos = x_pos;
        this.y_pos = y_pos;

        },

remove_node: function ( skill_id ) {
    var current = this._head, previous;
    if (skill_id != null && current != null ) { 
        while ( current.skill_id != skill_id ) {
            previous = current;
            current = current.next;
        }

        if ( current.skill_id == skill_id )
            console.log('found the skill_id');
        if (current != null) {
            if ( current.next != null ) {
                previous.next = current.next;
                return current;
            }else {
                previous = null;
                current = null;
                return current;
            }
        }
    }
    return null;
},

get_action_holder: function () {
    var current = this._head;

    var object_array = [];
    var i = 0;
    while (current != null) {
        object_array[i] = current;
        i++;
        current = current.next;
    }
    return object_array;
},
}

rendering

var action_image = main.action_holder.get_action_holder();
        for(var i = 0; i < action_image.length; i++) {
            main.game_handle.drawImage ( action_image[i].image_src , (  action_image[i].x_pos * 16 )  + main.player_x - ( main.game_x_pos * 16 ) , ( action_image[i].y_pos * 16 ) + main.player_y - ( main.game_y_pos * 16 ) );
            if ( action_image[i].turn_off == true )
                delete main.action_holder.remove_node(action_image[i].skill_id);
        }
  • 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-10T23:06:49+00:00Added an answer on June 10, 2026 at 11:06 pm

    Try this:

    if (current != null) {
        if (previous) {
            previous.next = current.next;
        }
        if (current.next) {
            current.next.previous = previous;
        }
        if (current == this._head) { // if the first node is removed, reset head to the next node
            this._head = current.next;
        }
        return current;
    }
    

    Inside add_node method:

    if (this._head === null) {
        this._head = node;
    } else {
        current = this._head;
    
        while (current.next) {
            current = current.next;
        }
        if (current != node) { // avoid circular reference
            current.next = node;
            node.previous = current; // set previous of the new node
        }
    }
    

    Test

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

Sidebar

Related Questions

I have been banging my head against the wall trying to figure out this
I've been banging my head against the wall all night trying to figure out
Been banging my head against this one for a while, and figured I'd turn
Been banging my head against this one for a while... <div id=pager style=top: 5px;
I have been banging my head against this for a little while now. I
I've been banging my head against for wall for a while with this one.
I have been banging my head against this one for a while now and
I've been banging my head against this issue for a while now and I'm
been banging my head against this one for a while. For a CSS redesign
I've been banging my head against the wall for hours trying to figure out

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.