Mintoris Forum

Author Topic: Extended Data Structure Support  (Read 3020 times)

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Extended Data Structure Support
« on: Nov 26, 2016, 11:10 PM »
I'm proposing an extension to the existing data structures.

It's time to add a dot to Basic's expression syntax.

hashtable = CreateHashTable()

old way:

put hashtable, name$, "name"
Get hashtable, n$, "name"

new way:

hashtable.name = name$
name$ = hashtable.name


Stacks and Queues work the same:

stack = CreateStack()

stack = name1$
stack = name2$
stack = name3$

name3$ = stack
name2$ = stack
name1$ = stack

queue = CreateQueue()

queue = name1$
queue = name2$
queue = name3$

name1$ = queue
name2$ = queue
name3$ = queue

Array Lists would work more like arrays.

arraylist = CreateArrayList()

arraylist = name$

name$ is added to the end of the list.

arraylist(3) = name$

element 3 of the array list will be set to name$ with some errors resulting if the element does not exist in the list. If element 3 was one past the end of the list it would be added to the end without an error.

name$ = arraylist(3)

name$ is set to element 3 if it exists.

name$ = arraylist ? return the last (or first) item on the list (tell me what you think)

Sparse arrays would work similar to array lists (with the obvious differences)

slick huh? Let me know what you think.

« Last Edit: Nov 28, 2016, 02:57 AM by Chuck »

sraffens

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 220
Re: Extended Data Structure Support
« Reply #1 on: Nov 27, 2016, 12:08 AM »
This would be nice.

Would the syntax like

hashtable.name = funcMakeName$("something")

be allowed or are variables only like the old way.


Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: Extended Data Structure Support
« Reply #2 on: Nov 27, 2016, 05:49 AM »
I want to be able to drill down to any data item no matter how complex the data structures are. I'm still trying to think of how to address an array of arraylists and the like.

I'm thinking if you had an array of arraylists it would be

array(n).(z) = 5

since the array list has no name. The dot and second subscript is the array list.


if you had a hash table of hash tables and the second hash table contained arrays it would be:

hashtable.key1.key2.(n)

I'm still trying to figure out how to address a hash table of stacks say. Stacks have neither key or index.

hashtable.key.?






« Last Edit: Nov 27, 2016, 06:39 AM by Chuck »

sraffens

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 220
Re: Extended Data Structure Support
« Reply #3 on: Nov 28, 2016, 12:39 AM »
I wounder if a method like call would work.

array(n).op(z) = 5
hashtable.key1.key2.op(n) = 5
hashtable.key.op() = 5

var = array(n).op(z)
var = hashtable.key1.key2.op(n)
var = hashtable.key.op()

Or something that would cause the put or the get operation not the assignment

stack = CreateStack()

stack.op() = name1$
stack.op() = name2$
stack.op() = name3$

name3$ = stack.op()
name2$ = stack.op()
name1$ = stack.op()

queue = CreateQueue()

queue.op() = name1$
queue.op() = name2$
queue.op() = name3$

name1$ = queue.op()
name2$ = queue.op()
name3$ = queue.op()

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: Extended Data Structure Support
« Reply #4 on: Nov 28, 2016, 02:57 AM »
I was thinking we already have the get and put keywords. They could be used in place of the missing key.

hashtable.key.put(4) = hashtable.key.get(7)

Or, if its just a hashtable of simple variables, stacks or queues:

hashtable.key.put = hashtable.key.get


sraffens

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 220
Re: Extended Data Structure Support
« Reply #5 on: Nov 28, 2016, 03:18 AM »
I was looking for the same. The = position indicates the operation.
Maybe a single character, "‼"

hashtable.key‼ = hashtable.key‼
hashtable.key‼(4) = hashtable.key‼(7)

sraffens

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 220
Re: Extended Data Structure Support
« Reply #6 on: Jan 17, 2018, 06:27 PM »
I was writing and I found my self-wishing there was an easier way to use data structures,  and the ease of using data structures has been requested.

I'm proposing an extension to the existing data structures.

It's time to add a dot to Basic's expression syntax.

hashtable = CreateHashTable()

old way:

put hashtable, name$, "name"
Get hashtable, n$, "name"

new way:

hashtable.name = name$
name$ = hashtable.name


Stacks and Queues work the same:

stack = CreateStack()

stack = name1$
stack = name2$
stack = name3$

name3$ = stack
name2$ = stack
name1$ = stack

queue = CreateQueue()

queue = name1$
queue = name2$
queue = name3$

name1$ = queue
name2$ = queue
name3$ = queue

Array Lists would work more like arrays.

arraylist = CreateArrayList()

arraylist = name$

name$ is added to the end of the list.

arraylist(3) = name$

element 3 of the array list will be set to name$ with some errors resulting if the element does not exist in the list. If element 3 was one past the end of the list it would be added to the end without an error.

name$ = arraylist(3)

name$ is set to element 3 if it exists.

name$ = arraylist ? return the last (or first) item on the list (tell me what you think)

Sparse arrays would work similar to array lists (with the obvious differences)

slick huh? Let me know what you think.

I would not be concerned about return the last (or first) item.
name$ = arraylist - this is an error - not a valid operation with ArrayList()

if concerned about return the last (or first) item.
name$ = datastuct(3)
datastuct(3) = name$
         maybe this functionality should be added to CreateStack() and CreateQueue() or NOT.

I had always thought of CreateArrayList() as an odd duck,
Add like CreateQueue() or CreateStack() and remove like CreateSparseArray()

SparseArray would act likes an array.

sparsearray = CreateSparseArray()
sparsearray(3) = name$
name$ = sparsearray(3)


ArrayList would act likes?  a list with half of an array function.

arraylist = CreateArrayList()

arraylist = name$

name$ = arraylist(3)
name$ = arraylist - this is an error - not a valid operation with ArrayList()

The following can be used for Stack, Queue, ArrayList, and SparseArray

  LIFO - like a stack - returns the last item on the list -
  FIFO - like a queue - returns the first item on the list -
array = CreateArray() - with LIFO or FIFO access

array = name$
name$ = array({LIFO|FIFO}) - Defined behavior, first Item or last item
name$ = array(3)
array(3) = name$

  returns the last item on the list - LIFO - like a stack
arraylifo = CreateArrayLifo()

arraylifo = name$
name$ = arraylifo - Defined behavior - last item
name$ = arraylifo (3)
arraylifo (3) = name$ - the array part is complete

  returns the first item on the list - FIFO - like a queue
arrayfifo = CreateArrayFifo()

arrayfifo = name$
name$ = arrayfifo - Defined behavior - first item
name$ = arrayfifo (3)
arrayfifo (3) = name$ - the array part is complete



This is my 2 cents
« Last Edit: Aug 26, 2018, 11:46 PM by Mintoris »

sraffens

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 220
Re: Extended Data Structure Support
« Reply #7 on: Jan 18, 2018, 05:37 PM »
In the other post, I was stuck on functions in a data structure, sorry.

I would use the data structure a lot more with the new syntax.
I tried having wrapper functions and the syntax was very clunky.
I stopped using data structure and I have been using globals.
A lot of globals is hard for me to use, I will get over it.

Thanks, all that you do

Scott

harold

  • Sr. Member
  • ****
  • Posts: 807
  • My Favorite Material Posession
    • MyElectronicArt
Re: Extended Data Structure Support
« Reply #8 on: Jan 18, 2018, 06:34 PM »
Hello, I figgured that might be more than I could handle, thanks, Harold.

EvelynDoobe

  • Full Member
  • ***
  • Posts: 31
Extended Data Structure Support
« Reply #9 on: Oct 18, 2019, 08:20 PM »
I would think that UEFI bootcamp would quickly become the default configuration for anyone wanting to do a double or triple boot configuration with Windows as one of the boot options? Still thanks for all the help.

Marietoupt

  • Full Member
  • ***
  • Posts: 31
Extended Data Structure Support
« Reply #10 on: Oct 18, 2019, 11:04 PM »
I'd like to use the DeployStudio REST API as a user with read-only access. In other words, a group member like that specified in the 'adminGroup' preference key, except have access only to GET methods.