Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #32638 > unrolled thread
| Started by | jonas.thornvall@gmail.com |
|---|---|
| First post | 2017-02-16 01:53 -0800 |
| Last post | 2017-02-18 12:14 -0800 |
| Articles | 10 — 1 participant |
Back to article view | Back to comp.lang.javascript
Programming strategies jonas.thornvall@gmail.com - 2017-02-16 01:53 -0800
Re: Programming strategies jonas.thornvall@gmail.com - 2017-02-17 02:22 -0800
Re: Programming strategies jonas.thornvall@gmail.com - 2017-02-17 03:39 -0800
Re: Programming strategies jonas.thornvall@gmail.com - 2017-02-18 04:46 -0800
Re: Programming strategies jonas.thornvall@gmail.com - 2017-02-18 05:03 -0800
Re: Programming strategies jonas.thornvall@gmail.com - 2017-02-18 05:20 -0800
Re: Programming strategies jonas.thornvall@gmail.com - 2017-02-18 05:34 -0800
Re: Programming strategies jonas.thornvall@gmail.com - 2017-02-18 05:58 -0800
Re: Programming strategies jonas.thornvall@gmail.com - 2017-02-18 07:16 -0800
Re: Programming strategies jonas.thornvall@gmail.com - 2017-02-18 12:14 -0800
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-16 01:53 -0800 |
| Subject | Programming strategies |
| Message-ID | <bcd07ea6-93e9-4544-bb05-e09ff1e0e5fa@googlegroups.com> |
I have a script using arrays where each entry points to x other array entries. I think i made the mistake to led the element index itself represent the node number/index. Since i autogenerated my graph and nodes i did not really think i thru. But now that i started to build a simple edit tool for the graph the problem become appearant. When i remove a node splice all following nodes get relabeled, so the linking of nodes totally become garbeled up. I could enforce a label/attribute called nodeindex upon the array that is probably easy to achieve, or i could do a reorder of the linkings it seem alot more job. This type of problem must been common in the old register days with use of multidimensional arrays, how was it solved back then and how is it solved today with objectoriented programming? Is there some objectoriented approach that make these kind of index issued problematics dissapear?
[toc] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-17 02:22 -0800 |
| Message-ID | <d9e53f7a-56bb-4c63-8d86-bf9d986404b1@googlegroups.com> |
| In reply to | #32638 |
Den torsdag 16 februari 2017 kl. 10:53:49 UTC+1 skrev jonas.t...@gmail.com: > I have a script using arrays where each entry points to x other array entries. > > I think i made the mistake to led the element index itself represent the node number/index. > > Since i autogenerated my graph and nodes i did not really think i thru. But now that i started to build a simple edit tool for the graph the problem become appearant. > > When i remove a node splice all following nodes get relabeled, so the linking of nodes totally become garbeled up. > > I could enforce a label/attribute called nodeindex upon the array that is probably easy to achieve, or i could do a reorder of the linkings it seem alot more job. > > This type of problem must been common in the old register days with use of multidimensional arrays, how was it solved back then and how is it solved today with objectoriented programming? > > Is there some objectoriented approach that make these kind of index issued problematics dissapear? I've seen suggestions that one should not delete the element, just set the element to null. I don't think that is so nice but it probably easiest way for me to get away with my mistake. Probably that is how it was handled in the structured programming era. And since i really use printnode rather than the actual array at printout on canvas maybe i do not even need to null it just set a flag on element that let printout know it is not for use. Right now it seem like the easiest option. Can object oriented languages be smart and understand how elements and their attributes fit together and automatically solve issues like this?
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-17 03:39 -0800 |
| Message-ID | <f6b5c3dc-872f-4c6b-ade4-44d523718e15@googlegroups.com> |
| In reply to | #32640 |
Den fredag 17 februari 2017 kl. 11:22:33 UTC+1 skrev jonas.t...@gmail.com: > Den torsdag 16 februari 2017 kl. 10:53:49 UTC+1 skrev jonas.t...@gmail.com: > > I have a script using arrays where each entry points to x other array entries. > > > > I think i made the mistake to led the element index itself represent the node number/index. > > > > Since i autogenerated my graph and nodes i did not really think i thru. But now that i started to build a simple edit tool for the graph the problem become appearant. > > > > When i remove a node splice all following nodes get relabeled, so the linking of nodes totally become garbeled up. > > > > I could enforce a label/attribute called nodeindex upon the array that is probably easy to achieve, or i could do a reorder of the linkings it seem alot more job. > > > > This type of problem must been common in the old register days with use of multidimensional arrays, how was it solved back then and how is it solved today with objectoriented programming? > > > > Is there some objectoriented approach that make these kind of index issued problematics dissapear? > > I've seen suggestions that one should not delete the element, just set the element to null. I don't think that is so nice but it probably easiest way for me to get away with my mistake. Probably that is how it was handled in the structured programming era. And since i really use printnode rather than the actual array at printout on canvas maybe i do not even need to null it just set a flag on element that let printout know it is not for use. > > Right now it seem like the easiest option. > > Can object oriented languages be smart and understand how elements and their attributes fit together and automatically solve issues like this? well of course i need to erase any linking to it, but that is what to expect.
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-18 04:46 -0800 |
| Message-ID | <dc53c610-705e-4e48-b03d-d5b5fe515e90@googlegroups.com> |
| In reply to | #32641 |
Den fredag 17 februari 2017 kl. 12:39:36 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 17 februari 2017 kl. 11:22:33 UTC+1 skrev jonas.t...@gmail.com:
> > Den torsdag 16 februari 2017 kl. 10:53:49 UTC+1 skrev jonas.t...@gmail.com:
> > > I have a script using arrays where each entry points to x other array entries.
> > >
> > > I think i made the mistake to led the element index itself represent the node number/index.
> > >
> > > Since i autogenerated my graph and nodes i did not really think i thru. But now that i started to build a simple edit tool for the graph the problem become appearant.
> > >
> > > When i remove a node splice all following nodes get relabeled, so the linking of nodes totally become garbeled up.
> > >
> > > I could enforce a label/attribute called nodeindex upon the array that is probably easy to achieve, or i could do a reorder of the linkings it seem alot more job.
> > >
> > > This type of problem must been common in the old register days with use of multidimensional arrays, how was it solved back then and how is it solved today with objectoriented programming?
> > >
> > > Is there some objectoriented approach that make these kind of index issued problematics dissapear?
> >
> > I've seen suggestions that one should not delete the element, just set the element to null. I don't think that is so nice but it probably easiest way for me to get away with my mistake. Probably that is how it was handled in the structured programming era. And since i really use printnode rather than the actual array at printout on canvas maybe i do not even need to null it just set a flag on element that let printout know it is not for use.
> >
> > Right now it seem like the easiest option.
> >
> > Can object oriented languages be smart and understand how elements and their attributes fit together and automatically solve issues like this?
>
> well of course i need to erase any linking to it, but that is what to expect.
The strategy work good so remove nodes no problem, but i have problem with splice subarray element could someone help me howto do it, i can't find examples?
function removeNode(){
for(var t = 0; t < nodes; t ++ )
{
if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
{
if (t > -1) {
//alert("removeNode");
arr[t].print=false;
for (var s=0;s<arr[t].nodelinks.length;s++){
remove=arr[t].nodelinks[s];
arr[remove].nodelinks[t].splice(remove,1); <--------SYNTAX ERROR
}
}
}
}
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-18 05:03 -0800 |
| Message-ID | <a69e91af-d8f6-4f10-a23e-ca50a2094759@googlegroups.com> |
| In reply to | #32643 |
Den lördag 18 februari 2017 kl. 13:46:19 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 17 februari 2017 kl. 12:39:36 UTC+1 skrev jonas.t...@gmail.com:
> > Den fredag 17 februari 2017 kl. 11:22:33 UTC+1 skrev jonas.t...@gmail.com:
> > > Den torsdag 16 februari 2017 kl. 10:53:49 UTC+1 skrev jonas.t...@gmail.com:
> > > > I have a script using arrays where each entry points to x other array entries.
> > > >
> > > > I think i made the mistake to led the element index itself represent the node number/index.
> > > >
> > > > Since i autogenerated my graph and nodes i did not really think i thru. But now that i started to build a simple edit tool for the graph the problem become appearant.
> > > >
> > > > When i remove a node splice all following nodes get relabeled, so the linking of nodes totally become garbeled up.
> > > >
> > > > I could enforce a label/attribute called nodeindex upon the array that is probably easy to achieve, or i could do a reorder of the linkings it seem alot more job.
> > > >
> > > > This type of problem must been common in the old register days with use of multidimensional arrays, how was it solved back then and how is it solved today with objectoriented programming?
> > > >
> > > > Is there some objectoriented approach that make these kind of index issued problematics dissapear?
> > >
> > > I've seen suggestions that one should not delete the element, just set the element to null. I don't think that is so nice but it probably easiest way for me to get away with my mistake. Probably that is how it was handled in the structured programming era. And since i really use printnode rather than the actual array at printout on canvas maybe i do not even need to null it just set a flag on element that let printout know it is not for use.
> > >
> > > Right now it seem like the easiest option.
> > >
> > > Can object oriented languages be smart and understand how elements and their attributes fit together and automatically solve issues like this?
> >
> > well of course i need to erase any linking to it, but that is what to expect.
>
> The strategy work good so remove nodes no problem, but i have problem with splice subarray element could someone help me howto do it, i can't find examples?
>
> function removeNode(){
> for(var t = 0; t < nodes; t ++ )
> {
> if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
> {
> if (t > -1) {
> //alert("removeNode");
> arr[t].print=false;
> for (var s=0;s<arr[t].nodelinks.length;s++){
> remove=arr[t].nodelinks[s];
> arr[remove].nodelinks[t].splice(remove,1); <--------SYNTAX ERROR
> }
> }
> }
> }
Sorry of course i should remove nodlink t but the the real problem syntax error remain
arr[remove].nodelinks[t].splice(t,1);
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-18 05:20 -0800 |
| Message-ID | <df48319d-ceb8-4c8f-bc86-699843b169bb@googlegroups.com> |
| In reply to | #32644 |
Den lördag 18 februari 2017 kl. 14:03:48 UTC+1 skrev jonas.t...@gmail.com:
> Den lördag 18 februari 2017 kl. 13:46:19 UTC+1 skrev jonas.t...@gmail.com:
> > Den fredag 17 februari 2017 kl. 12:39:36 UTC+1 skrev jonas.t...@gmail.com:
> > > Den fredag 17 februari 2017 kl. 11:22:33 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den torsdag 16 februari 2017 kl. 10:53:49 UTC+1 skrev jonas.t...@gmail.com:
> > > > > I have a script using arrays where each entry points to x other array entries.
> > > > >
> > > > > I think i made the mistake to led the element index itself represent the node number/index.
> > > > >
> > > > > Since i autogenerated my graph and nodes i did not really think i thru. But now that i started to build a simple edit tool for the graph the problem become appearant.
> > > > >
> > > > > When i remove a node splice all following nodes get relabeled, so the linking of nodes totally become garbeled up.
> > > > >
> > > > > I could enforce a label/attribute called nodeindex upon the array that is probably easy to achieve, or i could do a reorder of the linkings it seem alot more job.
> > > > >
> > > > > This type of problem must been common in the old register days with use of multidimensional arrays, how was it solved back then and how is it solved today with objectoriented programming?
> > > > >
> > > > > Is there some objectoriented approach that make these kind of index issued problematics dissapear?
> > > >
> > > > I've seen suggestions that one should not delete the element, just set the element to null. I don't think that is so nice but it probably easiest way for me to get away with my mistake. Probably that is how it was handled in the structured programming era. And since i really use printnode rather than the actual array at printout on canvas maybe i do not even need to null it just set a flag on element that let printout know it is not for use.
> > > >
> > > > Right now it seem like the easiest option.
> > > >
> > > > Can object oriented languages be smart and understand how elements and their attributes fit together and automatically solve issues like this?
> > >
> > > well of course i need to erase any linking to it, but that is what to expect.
> >
> > The strategy work good so remove nodes no problem, but i have problem with splice subarray element could someone help me howto do it, i can't find examples?
> >
> > function removeNode(){
> > for(var t = 0; t < nodes; t ++ )
> > {
> > if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
> > {
> > if (t > -1) {
> > //alert("removeNode");
> > arr[t].print=false;
> > for (var s=0;s<arr[t].nodelinks.length;s++){
> > remove=arr[t].nodelinks[s];
> > arr[remove].nodelinks[t].splice(remove,1); <--------SYNTAX ERROR
> > }
> > }
> > }
> > }
>
> Sorry of course i should remove nodlink t but the the real problem syntax error remain
> arr[remove].nodelinks[t].splice(t,1);
Correct syntax but only remove one link strange.
function removeNode(){
for(var t = 0; t < nodes; t ++ )
{
if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
{
if (t > -1) {
//alert("removeNode");
arr[t].print=false;
for (var s=0;s<arr[t].nodelinks.length;s++){
remove=arr[t].nodelinks[s];
arr[remove].nodelinks.splice(t,1);
// arr[t].nodelinks.splice(remove,1);
}
}
}
}
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-18 05:34 -0800 |
| Message-ID | <8885623b-fe8f-434c-87c2-e565dd4289d7@googlegroups.com> |
| In reply to | #32645 |
Den lördag 18 februari 2017 kl. 14:20:23 UTC+1 skrev jonas.t...@gmail.com:
> Den lördag 18 februari 2017 kl. 14:03:48 UTC+1 skrev jonas.t...@gmail.com:
> > Den lördag 18 februari 2017 kl. 13:46:19 UTC+1 skrev jonas.t...@gmail.com:
> > > Den fredag 17 februari 2017 kl. 12:39:36 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den fredag 17 februari 2017 kl. 11:22:33 UTC+1 skrev jonas.t...@gmail.com:
> > > > > Den torsdag 16 februari 2017 kl. 10:53:49 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > I have a script using arrays where each entry points to x other array entries.
> > > > > >
> > > > > > I think i made the mistake to led the element index itself represent the node number/index.
> > > > > >
> > > > > > Since i autogenerated my graph and nodes i did not really think i thru. But now that i started to build a simple edit tool for the graph the problem become appearant.
> > > > > >
> > > > > > When i remove a node splice all following nodes get relabeled, so the linking of nodes totally become garbeled up.
> > > > > >
> > > > > > I could enforce a label/attribute called nodeindex upon the array that is probably easy to achieve, or i could do a reorder of the linkings it seem alot more job.
> > > > > >
> > > > > > This type of problem must been common in the old register days with use of multidimensional arrays, how was it solved back then and how is it solved today with objectoriented programming?
> > > > > >
> > > > > > Is there some objectoriented approach that make these kind of index issued problematics dissapear?
> > > > >
> > > > > I've seen suggestions that one should not delete the element, just set the element to null. I don't think that is so nice but it probably easiest way for me to get away with my mistake. Probably that is how it was handled in the structured programming era. And since i really use printnode rather than the actual array at printout on canvas maybe i do not even need to null it just set a flag on element that let printout know it is not for use.
> > > > >
> > > > > Right now it seem like the easiest option.
> > > > >
> > > > > Can object oriented languages be smart and understand how elements and their attributes fit together and automatically solve issues like this?
> > > >
> > > > well of course i need to erase any linking to it, but that is what to expect.
> > >
> > > The strategy work good so remove nodes no problem, but i have problem with splice subarray element could someone help me howto do it, i can't find examples?
> > >
> > > function removeNode(){
> > > for(var t = 0; t < nodes; t ++ )
> > > {
> > > if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
> > > {
> > > if (t > -1) {
> > > //alert("removeNode");
> > > arr[t].print=false;
> > > for (var s=0;s<arr[t].nodelinks.length;s++){
> > > remove=arr[t].nodelinks[s];
> > > arr[remove].nodelinks[t].splice(remove,1); <--------SYNTAX ERROR
> > > }
> > > }
> > > }
> > > }
> >
> > Sorry of course i should remove nodlink t but the the real problem syntax error remain
> > arr[remove].nodelinks[t].splice(t,1);
>
> Correct syntax but only remove one link strange.
>
> function removeNode(){
> for(var t = 0; t < nodes; t ++ )
> {
> if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
> {
> if (t > -1) {
> //alert("removeNode");
> arr[t].print=false;
> for (var s=0;s<arr[t].nodelinks.length;s++){
> remove=arr[t].nodelinks[s];
> arr[remove].nodelinks.splice(t,1);
> // arr[t].nodelinks.splice(remove,1);
> }
> }
> }
> }
It strange only remove two nodes
function removeNode(){
for(var t = 0; t < nodes; t ++ )
{
if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
{
if (t > -1) {
//alert("removeNode");
arr[t].print=false;
var tr=arr[t].nodelinks.length;
for (s=0;s<tr;s++){
remove=arr[t].nodelinks[s];
arr[remove].nodelinks.splice(t,1);
}
}
}
}
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-18 05:58 -0800 |
| Message-ID | <086ea27c-d377-4ddf-88f1-b94e5e4a34ea@googlegroups.com> |
| In reply to | #32646 |
Den lördag 18 februari 2017 kl. 14:34:16 UTC+1 skrev jonas.t...@gmail.com:
> Den lördag 18 februari 2017 kl. 14:20:23 UTC+1 skrev jonas.t...@gmail.com:
> > Den lördag 18 februari 2017 kl. 14:03:48 UTC+1 skrev jonas.t...@gmail.com:
> > > Den lördag 18 februari 2017 kl. 13:46:19 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den fredag 17 februari 2017 kl. 12:39:36 UTC+1 skrev jonas.t...@gmail.com:
> > > > > Den fredag 17 februari 2017 kl. 11:22:33 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > Den torsdag 16 februari 2017 kl. 10:53:49 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > I have a script using arrays where each entry points to x other array entries.
> > > > > > >
> > > > > > > I think i made the mistake to led the element index itself represent the node number/index.
> > > > > > >
> > > > > > > Since i autogenerated my graph and nodes i did not really think i thru. But now that i started to build a simple edit tool for the graph the problem become appearant.
> > > > > > >
> > > > > > > When i remove a node splice all following nodes get relabeled, so the linking of nodes totally become garbeled up.
> > > > > > >
> > > > > > > I could enforce a label/attribute called nodeindex upon the array that is probably easy to achieve, or i could do a reorder of the linkings it seem alot more job.
> > > > > > >
> > > > > > > This type of problem must been common in the old register days with use of multidimensional arrays, how was it solved back then and how is it solved today with objectoriented programming?
> > > > > > >
> > > > > > > Is there some objectoriented approach that make these kind of index issued problematics dissapear?
> > > > > >
> > > > > > I've seen suggestions that one should not delete the element, just set the element to null. I don't think that is so nice but it probably easiest way for me to get away with my mistake. Probably that is how it was handled in the structured programming era. And since i really use printnode rather than the actual array at printout on canvas maybe i do not even need to null it just set a flag on element that let printout know it is not for use.
> > > > > >
> > > > > > Right now it seem like the easiest option.
> > > > > >
> > > > > > Can object oriented languages be smart and understand how elements and their attributes fit together and automatically solve issues like this?
> > > > >
> > > > > well of course i need to erase any linking to it, but that is what to expect.
> > > >
> > > > The strategy work good so remove nodes no problem, but i have problem with splice subarray element could someone help me howto do it, i can't find examples?
> > > >
> > > > function removeNode(){
> > > > for(var t = 0; t < nodes; t ++ )
> > > > {
> > > > if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
> > > > {
> > > > if (t > -1) {
> > > > //alert("removeNode");
> > > > arr[t].print=false;
> > > > for (var s=0;s<arr[t].nodelinks.length;s++){
> > > > remove=arr[t].nodelinks[s];
> > > > arr[remove].nodelinks[t].splice(remove,1); <--------SYNTAX ERROR
> > > > }
> > > > }
> > > > }
> > > > }
> > >
> > > Sorry of course i should remove nodlink t but the the real problem syntax error remain
> > > arr[remove].nodelinks[t].splice(t,1);
> >
> > Correct syntax but only remove one link strange.
> >
> > function removeNode(){
> > for(var t = 0; t < nodes; t ++ )
> > {
> > if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
> > {
> > if (t > -1) {
> > //alert("removeNode");
> > arr[t].print=false;
> > for (var s=0;s<arr[t].nodelinks.length;s++){
> > remove=arr[t].nodelinks[s];
> > arr[remove].nodelinks.splice(t,1);
> > // arr[t].nodelinks.splice(remove,1);
> > }
> > }
> > }
> > }
>
>
> It strange only remove two nodes
> function removeNode(){
> for(var t = 0; t < nodes; t ++ )
> {
> if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
> {
> if (t > -1) {
> //alert("removeNode");
> arr[t].print=false;
> var tr=arr[t].nodelinks.length;
> for (s=0;s<tr;s++){
> remove=arr[t].nodelinks[s];
> arr[remove].nodelinks.splice(t,1);
> }
> }
> }
> }
Done
function removeNode(){
for(var t = 0; t < nodes; t ++ )
{
if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
{
if (t > -1) {
arr[t].print=false;
var tr=arr[t].nodelinks.length;
alert(tr);
for (s=0;s<tr;s++){
remove=arr[t].nodelinks[s];
var x=0;
while (x<tr){
if (arr[remove].nodelinks[x]==t){
arr[remove].nodelinks.splice(x,1);
}
x++;
}
}
}
}
}
}
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-18 07:16 -0800 |
| Message-ID | <9346409d-ea19-4b24-b9ba-4679440527b0@googlegroups.com> |
| In reply to | #32647 |
Den lördag 18 februari 2017 kl. 14:58:21 UTC+1 skrev jonas.t...@gmail.com:
> Den lördag 18 februari 2017 kl. 14:34:16 UTC+1 skrev jonas.t...@gmail.com:
> > Den lördag 18 februari 2017 kl. 14:20:23 UTC+1 skrev jonas.t...@gmail.com:
> > > Den lördag 18 februari 2017 kl. 14:03:48 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den lördag 18 februari 2017 kl. 13:46:19 UTC+1 skrev jonas.t...@gmail.com:
> > > > > Den fredag 17 februari 2017 kl. 12:39:36 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > Den fredag 17 februari 2017 kl. 11:22:33 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > Den torsdag 16 februari 2017 kl. 10:53:49 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > > I have a script using arrays where each entry points to x other array entries.
> > > > > > > >
> > > > > > > > I think i made the mistake to led the element index itself represent the node number/index.
> > > > > > > >
> > > > > > > > Since i autogenerated my graph and nodes i did not really think i thru. But now that i started to build a simple edit tool for the graph the problem become appearant.
> > > > > > > >
> > > > > > > > When i remove a node splice all following nodes get relabeled, so the linking of nodes totally become garbeled up.
> > > > > > > >
> > > > > > > > I could enforce a label/attribute called nodeindex upon the array that is probably easy to achieve, or i could do a reorder of the linkings it seem alot more job.
> > > > > > > >
> > > > > > > > This type of problem must been common in the old register days with use of multidimensional arrays, how was it solved back then and how is it solved today with objectoriented programming?
> > > > > > > >
> > > > > > > > Is there some objectoriented approach that make these kind of index issued problematics dissapear?
> > > > > > >
> > > > > > > I've seen suggestions that one should not delete the element, just set the element to null. I don't think that is so nice but it probably easiest way for me to get away with my mistake. Probably that is how it was handled in the structured programming era. And since i really use printnode rather than the actual array at printout on canvas maybe i do not even need to null it just set a flag on element that let printout know it is not for use.
> > > > > > >
> > > > > > > Right now it seem like the easiest option.
> > > > > > >
> > > > > > > Can object oriented languages be smart and understand how elements and their attributes fit together and automatically solve issues like this?
> > > > > >
> > > > > > well of course i need to erase any linking to it, but that is what to expect.
> > > > >
> > > > > The strategy work good so remove nodes no problem, but i have problem with splice subarray element could someone help me howto do it, i can't find examples?
> > > > >
> > > > > function removeNode(){
> > > > > for(var t = 0; t < nodes; t ++ )
> > > > > {
> > > > > if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
> > > > > {
> > > > > if (t > -1) {
> > > > > //alert("removeNode");
> > > > > arr[t].print=false;
> > > > > for (var s=0;s<arr[t].nodelinks.length;s++){
> > > > > remove=arr[t].nodelinks[s];
> > > > > arr[remove].nodelinks[t].splice(remove,1); <--------SYNTAX ERROR
> > > > > }
> > > > > }
> > > > > }
> > > > > }
> > > >
> > > > Sorry of course i should remove nodlink t but the the real problem syntax error remain
> > > > arr[remove].nodelinks[t].splice(t,1);
> > >
> > > Correct syntax but only remove one link strange.
> > >
> > > function removeNode(){
> > > for(var t = 0; t < nodes; t ++ )
> > > {
> > > if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
> > > {
> > > if (t > -1) {
> > > //alert("removeNode");
> > > arr[t].print=false;
> > > for (var s=0;s<arr[t].nodelinks.length;s++){
> > > remove=arr[t].nodelinks[s];
> > > arr[remove].nodelinks.splice(t,1);
> > > // arr[t].nodelinks.splice(remove,1);
> > > }
> > > }
> > > }
> > > }
> >
> >
> > It strange only remove two nodes
> > function removeNode(){
> > for(var t = 0; t < nodes; t ++ )
> > {
> > if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
> > {
> > if (t > -1) {
> > //alert("removeNode");
> > arr[t].print=false;
> > var tr=arr[t].nodelinks.length;
> > for (s=0;s<tr;s++){
> > remove=arr[t].nodelinks[s];
> > arr[remove].nodelinks.splice(t,1);
> > }
> > }
> > }
> > }
>
> Done
>
> function removeNode(){
> for(var t = 0; t < nodes; t ++ )
> {
> if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
> {
> if (t > -1) {
> arr[t].print=false;
> var tr=arr[t].nodelinks.length;
> alert(tr);
> for (s=0;s<tr;s++){
> remove=arr[t].nodelinks[s];
> var x=0;
> while (x<tr){
> if (arr[remove].nodelinks[x]==t){
> arr[remove].nodelinks.splice(x,1);
> }
> x++;
> }
> }
> }
> }
> }
> }
http://anybase.co.nf/
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-18 12:14 -0800 |
| Message-ID | <1ef314a0-7451-4006-8068-f041809b67d4@googlegroups.com> |
| In reply to | #32648 |
Den lördag 18 februari 2017 kl. 16:16:26 UTC+1 skrev jonas.t...@gmail.com:
> Den lördag 18 februari 2017 kl. 14:58:21 UTC+1 skrev jonas.t...@gmail.com:
> > Den lördag 18 februari 2017 kl. 14:34:16 UTC+1 skrev jonas.t...@gmail.com:
> > > Den lördag 18 februari 2017 kl. 14:20:23 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den lördag 18 februari 2017 kl. 14:03:48 UTC+1 skrev jonas.t...@gmail.com:
> > > > > Den lördag 18 februari 2017 kl. 13:46:19 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > Den fredag 17 februari 2017 kl. 12:39:36 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > Den fredag 17 februari 2017 kl. 11:22:33 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > > Den torsdag 16 februari 2017 kl. 10:53:49 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > > > I have a script using arrays where each entry points to x other array entries.
> > > > > > > > >
> > > > > > > > > I think i made the mistake to led the element index itself represent the node number/index.
> > > > > > > > >
> > > > > > > > > Since i autogenerated my graph and nodes i did not really think i thru. But now that i started to build a simple edit tool for the graph the problem become appearant.
> > > > > > > > >
> > > > > > > > > When i remove a node splice all following nodes get relabeled, so the linking of nodes totally become garbeled up.
> > > > > > > > >
> > > > > > > > > I could enforce a label/attribute called nodeindex upon the array that is probably easy to achieve, or i could do a reorder of the linkings it seem alot more job.
> > > > > > > > >
> > > > > > > > > This type of problem must been common in the old register days with use of multidimensional arrays, how was it solved back then and how is it solved today with objectoriented programming?
> > > > > > > > >
> > > > > > > > > Is there some objectoriented approach that make these kind of index issued problematics dissapear?
> > > > > > > >
> > > > > > > > I've seen suggestions that one should not delete the element, just set the element to null. I don't think that is so nice but it probably easiest way for me to get away with my mistake. Probably that is how it was handled in the structured programming era. And since i really use printnode rather than the actual array at printout on canvas maybe i do not even need to null it just set a flag on element that let printout know it is not for use.
> > > > > > > >
> > > > > > > > Right now it seem like the easiest option.
> > > > > > > >
> > > > > > > > Can object oriented languages be smart and understand how elements and their attributes fit together and automatically solve issues like this?
> > > > > > >
> > > > > > > well of course i need to erase any linking to it, but that is what to expect.
> > > > > >
> > > > > > The strategy work good so remove nodes no problem, but i have problem with splice subarray element could someone help me howto do it, i can't find examples?
> > > > > >
> > > > > > function removeNode(){
> > > > > > for(var t = 0; t < nodes; t ++ )
> > > > > > {
> > > > > > if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
> > > > > > {
> > > > > > if (t > -1) {
> > > > > > //alert("removeNode");
> > > > > > arr[t].print=false;
> > > > > > for (var s=0;s<arr[t].nodelinks.length;s++){
> > > > > > remove=arr[t].nodelinks[s];
> > > > > > arr[remove].nodelinks[t].splice(remove,1); <--------SYNTAX ERROR
> > > > > > }
> > > > > > }
> > > > > > }
> > > > > > }
> > > > >
> > > > > Sorry of course i should remove nodlink t but the the real problem syntax error remain
> > > > > arr[remove].nodelinks[t].splice(t,1);
> > > >
> > > > Correct syntax but only remove one link strange.
> > > >
> > > > function removeNode(){
> > > > for(var t = 0; t < nodes; t ++ )
> > > > {
> > > > if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
> > > > {
> > > > if (t > -1) {
> > > > //alert("removeNode");
> > > > arr[t].print=false;
> > > > for (var s=0;s<arr[t].nodelinks.length;s++){
> > > > remove=arr[t].nodelinks[s];
> > > > arr[remove].nodelinks.splice(t,1);
> > > > // arr[t].nodelinks.splice(remove,1);
> > > > }
> > > > }
> > > > }
> > > > }
> > >
> > >
> > > It strange only remove two nodes
> > > function removeNode(){
> > > for(var t = 0; t < nodes; t ++ )
> > > {
> > > if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
> > > {
> > > if (t > -1) {
> > > //alert("removeNode");
> > > arr[t].print=false;
> > > var tr=arr[t].nodelinks.length;
> > > for (s=0;s<tr;s++){
> > > remove=arr[t].nodelinks[s];
> > > arr[remove].nodelinks.splice(t,1);
> > > }
> > > }
> > > }
> > > }
> >
> > Done
> >
> > function removeNode(){
> > for(var t = 0; t < nodes; t ++ )
> > {
> > if (mouseDown.x >= arr[t].rposX && mouseDown.x <= (arr[t].rposX + arr[t].rwidth) && mouseDown.y >= arr[t].rposY && mouseDown.y <= (arr[t].rposY + arr[t].rheigth))
> > {
> > if (t > -1) {
> > arr[t].print=false;
> > var tr=arr[t].nodelinks.length;
> > alert(tr);
> > for (s=0;s<tr;s++){
> > remove=arr[t].nodelinks[s];
> > var x=0;
> > while (x<tr){
> > if (arr[remove].nodelinks[x]==t){
> > arr[remove].nodelinks.splice(x,1);
> > }
> > x++;
> > }
> > }
> > }
> > }
> > }
> > }
>
> http://anybase.co.nf/
Well almost there is some sneaky behaviour
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web