 .. raw:: html
    <script type="text/javascript">
     $(function () {
       var moduleName = "link-nodes-practice-exercises";
       var sections = ['createlist', 'iterateoverlist', 'changepointeenext1', 'addnodeathead'];
       TimeMe.initialize({
         idleTimeoutInSeconds: 10
       });
       sections.forEach(function (section, i) {
         TimeMe.trackTimeOnElement(section);
       });
       var timeObj = {};
       setInterval(function () {
         timeObj[moduleName.substring(0, 5)] = TimeMe.getTimeOnCurrentPageInSeconds().toFixed(2);
         sections.forEach(function (section, i) {
           timeObj[i + "-" + section.substring(0, 5)] = TimeMe.getTimeOnElementInSeconds(section).toFixed(2);
         });
         for (var sec of sections) {
         }
         console.log(JSON.stringify(timeObj))
       }, 2000);
     });
    </script>
 
.. _Links2:


.. raw:: html

   <script>ODSA.SETTINGS.DISP_MOD_COMP = true;ODSA.SETTINGS.MODULE_NAME = "Links2";ODSA.SETTINGS.MODULE_LONG_NAME = "Link Nodes Practice Exercises";ODSA.SETTINGS.MODULE_CHAPTER = "modules"; ODSA.SETTINGS.BUILD_DATE = "2023-10-10 00:21:16"; ODSA.SETTINGS.BUILD_CMAP = false;JSAV_OPTIONS['lang']='en';JSAV_EXERCISE_OPTIONS['code']='java';</script>


.. |--| unicode:: U+2013   .. en dash
.. |---| unicode:: U+2014  .. em dash, trimming surrounding whitespace
   :trim:



.. odsalink:: AV/Pointers/linkNodes3CON.css

.. odsalink:: AV/Pointers/linkNodes4CON.css

.. odsalink:: AV/Pointers/linkNodes5CON.css
.. This file is part of the OpenDSA eTextbook project. See
.. http://opendsa.org for more details.
.. Copyright (c) 2012-2020 by the OpenDSA Project Contributors, and
.. distributed under an MIT open source license.

.. avmetadata::
   :author: Cliff Shaffer, Mohammed Mostafa, and Margaret Ellis
   :requires: Pointer intro
   :satisfies:
   :topic: Link Nodes

Link Nodes Practice Exercises
=============================

createList
----------

.. extrtoolembed:: 'createList'
   :module: Links2
   :long_name: createList
   :enable_scrolling: False
   :frame_width: 1000
   :frame_height: 900
   :learning_tool: code-workout
   :workout_id: 428



One can easily write a loop to iterate through all the Links on a
chain, without needing to know how many there actually are.

.. inlineav:: linkNodes3CON ss
   :output: show


iterateOverList
---------------

.. extrtoolembed:: 'iterateOverList'
   :module: Links2
   :long_name: iterateOverList
   :enable_scrolling: False
   :frame_width: 1000
   :frame_height: 900
   :learning_tool: code-workout
   :workout_id: 426



One can remove a Link from a chain.

.. inlineav:: linkNodes4CON ss
   :output: show


changePointeeNext1
------------------

.. extrtoolembed:: 'changePointeeNext1'
   :module: Links2
   :long_name: changePointeeNext1
   :enable_scrolling: False
   :frame_width: 1000
   :frame_height: 900
   :learning_tool: code-workout
   :workout_id: 424




Finally, we can also insert new Links.

.. inlineav:: linkNodes5CON ss
   :output: show


addNodeAtHead
-------------

.. extrtoolembed:: 'addNodeAtHead'
   :module: Links2
   :long_name: addNodeAtHead
   :enable_scrolling: False
   :frame_width: 1000
   :frame_height: 900
   :learning_tool: code-workout
   :workout_id: 429


.. odsascript:: AV/Pointers/linkNodes3CON.js
.. odsascript:: AV/Pointers/linkNodes4CON.js
.. odsascript:: AV/Pointers/linkNodes5CON.js
