Trouble with array of linked_list elements

2 messages Options
Embed this post
Permalink
Phung Dinh Vu

Trouble with array of linked_list elements

Reply Threaded More More options
Print post
Permalink
I represent an adjacency list of graph G(V,E).
feature
    adj_list: ARRAY[LINKED_LIST[INTEGER]]
feature
    make(vertices: INTEGER)
        local
            i: INTEGER
        do
            create adj_list.make(1,vertices)
            from
                i:=1
            until
                i > adj_list.upper
            loop
                create adj_list[i].make
                io.put_string("Enter the vertices match to vertex ")
                                io.put_integer(i)
                io.put_string (":%T")
                read_list(adj_list[i])
                i:=i+1
            end
        end

The compile said "expression cannot be used as instruction" at the stage "create adj_list[i].make " Does it make sense? Can anybody help me fix it?


helmut.brandl

Re: Trouble with array of linked_list elements

Reply Threaded More More options
Print post
Permalink
Just create the object and put it into the array:

   adj_list[i] := create {LINKED_LIST[INTEGER]}.make


Phung Dinh Vu wrote:

> I represent an adjacency list of graph G(V,E).
> feature
>     adj_list: ARRAY[LINKED_LIST[INTEGER]]
> feature
>     make(vertices: INTEGER)
>         local
>             i: INTEGER
>         do
>             create adj_list.make(1,vertices)
>             from
>                 i:=1
>             until
>                 i > adj_list.upper
>             loop
>                 create adj_list[i].make
>                 io.put_string("Enter the vertices match to vertex ")
>                                 io.put_integer(i)
>                 io.put_string (":%T")
>                 read_list(adj_list[i])
>                 i:=i+1
>             end
>         end
>
> The compile said "expression cannot be used as instruction" at the stage "create adj_list[i].make " Does it make sense? Can anybody help me fix it?
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>