array-usage + objects in general
in
Programming Questions
•
8 months ago
Hi folks, may I introduce myself: I'm the user that downloaded Processing last week.
I'm not totally new to programming - in the last 30 years or so I just used Basic (all kinds of) and I'm familiar in using OpenGL, but the fully object orientated stuff is kind a new to me.
Now a whole bunch of array+object-related questions:
Can arrays (of primitives or objects) be used dynamical?
In Basic there was always some "ReDim" or even better "Redim Preserve" to do that...
Can I change the count of array-elements that are "defined global" (outside curly braces) as I need them?
Does already set data get preserved then?
Can objects of same class have different count of sub-array-elements?
example:
obj1.numbers[ 10 elements]
obj2.numbers[ 20 elements]
right so far?
Can I still change the count of elements ("resize array.length?"), add or remove elements so maybe obj1 has 20 numbers or obj2 has just 10 numbers then - or are they fixed once the object is created?
And the second part of the question:
if it won't be obj1 and obj2, but an array obj[]
Can I destroy or delete single objects from an array?
all questions - if yes: How to?
btw. would the "opposite" of keyword new then be
obj[ desiredIndex] = null; // does this kill obj[ desiredIndex]???
ArrayLists are no option in my case - since I'm gonna deal with usually 3 to 20 objects (triangular shape lists), around 120 or 150 objects of this class (shape) will be the upper bound per document (mesh) and each of the shape lists will have 1000 up to 25000 elements (triangular faces) - maybe less or more, depends on what the user is drawing. Perhaps I'll limit this to 32000 faces per shape or so, but thats not much: a single sphere might have a couple of hundred faces - if using face normals (default view) it adds up quickly to thousands and more vertices...
I like the all-in-one-small-window-approach of Processing as a developing environment and also the quick setup and ready to run. The only thing that I miss is some code-overview to quickly access a certain position of the script. It doesn't need an extra treeview-control nor code-folding to do that: the menu-bar itself could very well do the job through noding the branches onto some sub-menu (maybe "Edit" or "Sketch") and this would'nt change the look of PDE. Bookmarks would also be handy.
I'm not totally new to programming - in the last 30 years or so I just used Basic (all kinds of) and I'm familiar in using OpenGL, but the fully object orientated stuff is kind a new to me.
Now a whole bunch of array+object-related questions:
Can arrays (of primitives or objects) be used dynamical?
In Basic there was always some "ReDim" or even better "Redim Preserve" to do that...
Can I change the count of array-elements that are "defined global" (outside curly braces) as I need them?
Does already set data get preserved then?
Can objects of same class have different count of sub-array-elements?
example:
- testclass obj1, obj2;
- void setup()
- {
- obj1 = new testclass(10);
- obj2 = new testclass(20);
- }
- // skip draw for this example...
- // ...
- class testclass
- {
- // class variables
- int[] numbers;
- // class constructor
- testclass(int _elementcount)
- {
- this.numbers[_elementcount] = 123; // just assign any senseless value...
- }
- }
obj1.numbers[ 10 elements]
obj2.numbers[ 20 elements]
right so far?
Can I still change the count of elements ("resize array.length?"), add or remove elements so maybe obj1 has 20 numbers or obj2 has just 10 numbers then - or are they fixed once the object is created?
And the second part of the question:
if it won't be obj1 and obj2, but an array obj[]
Can I destroy or delete single objects from an array?
all questions - if yes: How to?
btw. would the "opposite" of keyword new then be
obj[ desiredIndex] = null; // does this kill obj[ desiredIndex]???
ArrayLists are no option in my case - since I'm gonna deal with usually 3 to 20 objects (triangular shape lists), around 120 or 150 objects of this class (shape) will be the upper bound per document (mesh) and each of the shape lists will have 1000 up to 25000 elements (triangular faces) - maybe less or more, depends on what the user is drawing. Perhaps I'll limit this to 32000 faces per shape or so, but thats not much: a single sphere might have a couple of hundred faces - if using face normals (default view) it adds up quickly to thousands and more vertices...
I like the all-in-one-small-window-approach of Processing as a developing environment and also the quick setup and ready to run. The only thing that I miss is some code-overview to quickly access a certain position of the script. It doesn't need an extra treeview-control nor code-folding to do that: the menu-bar itself could very well do the job through noding the branches onto some sub-menu (maybe "Edit" or "Sketch") and this would'nt change the look of PDE. Bookmarks would also be handy.
1