Wednesday, 15 April 2015

algorithm - Memory usage of a node class of a LinkedList in java (enclosing instance reference) -


Sedgewick's algorithm 4 in the book 201 of the book, node Given as 40 bytes:

  class node {item item; Next node; Pause given:  
  • Object overhead = 16 bytes
  • Item reference = 8 bytes (= Memory address)

    There is an explanation for additional overhead:

    For the nested non-static (internal) class as our node class (page 142) Additional 8 bytes are required (for reference of attached charge)

    What is it / strong> is it mentioned? The node category contains only the items and the next variable.

    Can anyone explain it?

    Good says that node is a non-static internal is the class if the class was a stable inner class, then it could be present without a squared class. Since it is not not , it depends (this is a part) is defined in the example of an external class.

    Private class} {/ code> to use foo , I will have an enclosed bar , for example

      Fu Fu = New Bar () New foo ();   

    If foo was static, then I could

      fu fu = new bar.fu (); //To wit. New bar.fu ()   

    Therefore, you have to bar . <>

No comments:

Post a Comment