<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Mobile_Apps_2023W_Lecture_16</id>
	<title>Mobile Apps 2023W Lecture 16 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Mobile_Apps_2023W_Lecture_16"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Mobile_Apps_2023W_Lecture_16&amp;action=history"/>
	<updated>2026-04-08T03:16:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Mobile_Apps_2023W_Lecture_16&amp;diff=24387&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Notes==  &lt;pre&gt; March 10 --------  I have a hostname, want to insert it into the current HNTree  - split the hostname into a bunch of components     (www, carleton, ca)  First, initially, we&#039;ll create a root node representing . (top of the DNS hierarchy).  So that should get its own dedicated constructor.  Then we&#039;ll have an add operation which will take a hostname, and it will add child hostnames  add will split the hostname into its components, see if the last-most su...&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Mobile_Apps_2023W_Lecture_16&amp;diff=24387&amp;oldid=prev"/>
		<updated>2023-03-10T22:16:57Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Notes==  &amp;lt;pre&amp;gt; March 10 --------  I have a hostname, want to insert it into the current HNTree  - split the hostname into a bunch of components     (www, carleton, ca)  First, initially, we&amp;#039;ll create a root node representing . (top of the DNS hierarchy).  So that should get its own dedicated constructor.  Then we&amp;#039;ll have an add operation which will take a hostname, and it will add child hostnames  add will split the hostname into its components, see if the last-most su...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Notes==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
March 10&lt;br /&gt;
--------&lt;br /&gt;
&lt;br /&gt;
I have a hostname, want to insert it into the current HNTree&lt;br /&gt;
 - split the hostname into a bunch of components&lt;br /&gt;
    (www, carleton, ca)&lt;br /&gt;
&lt;br /&gt;
First, initially, we&amp;#039;ll create a root node representing . (top of the DNS hierarchy).  So that should get its own dedicated constructor.&lt;br /&gt;
&lt;br /&gt;
Then we&amp;#039;ll have an add operation which will take a hostname, and it will add child hostnames&lt;br /&gt;
&lt;br /&gt;
add will split the hostname into its components, see if the last-most suffix &lt;br /&gt;
&lt;br /&gt;
www.carleton.ca is the same as www.carleton.ca.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;kotlin&amp;quot; line&amp;gt;&lt;br /&gt;
package carleton.comp2601.historyviewer&lt;br /&gt;
&lt;br /&gt;
class HNTree {&lt;br /&gt;
    var hostComponent: String&lt;br /&gt;
    var hostSuffix: String&lt;br /&gt;
    var parent: HNTree&lt;br /&gt;
    var children: MutableList&amp;lt;HNTree&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    constructor() {&lt;br /&gt;
        /* Creates the &amp;quot;root&amp;quot; node by default, rest are created using&lt;br /&gt;
           different constructor&lt;br /&gt;
         */&lt;br /&gt;
        hostComponent = &amp;quot;&amp;quot;&lt;br /&gt;
        hostSuffix = &amp;quot;.&amp;quot;&lt;br /&gt;
        parent = this&lt;br /&gt;
        children = mutableListOf()&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    fun add(hostPrefix: String) {&lt;br /&gt;
        var allComponents: List&amp;lt;String&amp;gt;&lt;br /&gt;
        var component: String&lt;br /&gt;
        var child: HNTree? = null&lt;br /&gt;
&lt;br /&gt;
        /* still have to deal with getting to the end */&lt;br /&gt;
&lt;br /&gt;
        allComponents = hostPrefix.split(&amp;quot;.&amp;quot;)&lt;br /&gt;
        component = allComponents.last()&lt;br /&gt;
&lt;br /&gt;
        if (component == hostPrefix) {&lt;br /&gt;
            return&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        for (c in this.children) {&lt;br /&gt;
                 if (c.hostComponent == component) {&lt;br /&gt;
                     child = c&lt;br /&gt;
                     break&lt;br /&gt;
                 }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        if (child == null) {&lt;br /&gt;
            child = HNTree()&lt;br /&gt;
            child.parent = this&lt;br /&gt;
            child.hostComponent = component&lt;br /&gt;
            child.hostSuffix = &amp;quot;$component.$hostSuffix&amp;quot;&lt;br /&gt;
            children.add(child)&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        child.add(allComponents.dropLast(1).joinToString())&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>