summaryrefslogtreecommitdiff
path: root/src/Fl_Tree_Item_Array.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Fl_Tree_Item_Array.cxx')
-rw-r--r--src/Fl_Tree_Item_Array.cxx54
1 files changed, 24 insertions, 30 deletions
diff --git a/src/Fl_Tree_Item_Array.cxx b/src/Fl_Tree_Item_Array.cxx
index 0503a8000..dca358288 100644
--- a/src/Fl_Tree_Item_Array.cxx
+++ b/src/Fl_Tree_Item_Array.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
#include <stdio.h>
#include <stdlib.h>
@@ -20,18 +18,18 @@
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
-// http://www.fltk.org/COPYING.php
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
/// Constructor; creates an empty array.
///
/// The optional 'chunksize' can be specified to optimize
/// memory allocation for potentially large arrays. Default chunksize is 10.
-///
+///
Fl_Tree_Item_Array::Fl_Tree_Item_Array(int new_chunksize) {
_items = 0;
_total = 0;
@@ -54,11 +52,11 @@ Fl_Tree_Item_Array::Fl_Tree_Item_Array(const Fl_Tree_Item_Array* o) {
_flags = o->_flags;
for ( int t=0; t<o->_total; t++ ) {
if ( _flags & MANAGE_ITEM ) {
- _items[t] = new Fl_Tree_Item(o->_items[t]); // make new copy of item
+ _items[t] = new Fl_Tree_Item(o->_items[t]); // make new copy of item
++_total;
- _items[t]->update_prev_next(t); // update uses _total's current value
+ _items[t]->update_prev_next(t); // update uses _total's current value
} else {
- _items[t] = o->_items[t]; // copy ptr only
+ _items[t] = o->_items[t]; // copy ptr only
++_total;
}
}
@@ -75,7 +73,7 @@ void Fl_Tree_Item_Array::clear() {
if ( _flags & MANAGE_ITEM )
{
delete _items[t];
- _items[t] = 0;
+ _items[t] = 0;
}
}
free((void*)_items); _items = 0;
@@ -89,13 +87,13 @@ void Fl_Tree_Item_Array::clear() {
// Does NOT change total.
//
void Fl_Tree_Item_Array::enlarge(int count) {
- int newtotal = _total + count; // new total
- if ( newtotal >= _size ) { // more than we have allocated?
+ int newtotal = _total + count; // new total
+ if ( newtotal >= _size ) { // more than we have allocated?
if ( (newtotal/150) > _chunksize ) _chunksize *= 10;
// Increase size of array
int newsize = _size + _chunksize;
Fl_Tree_Item **newitems = (Fl_Tree_Item**)malloc(newsize * sizeof(Fl_Tree_Item*));
- if ( _items ) {
+ if ( _items ) {
// Copy old array -> new, delete old
memmove(newitems, _items, _size * sizeof(Fl_Tree_Item*));
free((void*)_items); _items = 0;
@@ -119,15 +117,15 @@ void Fl_Tree_Item_Array::insert(int pos, Fl_Tree_Item *new_item) {
pos = _total;
enlarge(1);
// printf("*** POS=%d TOTAL-1=%d NITEMS=%d\n", pos, _total-1, (_total-pos));
- if ( pos <= (_total - 1) ) { // need to move memory around?
+ if ( pos <= (_total - 1) ) { // need to move memory around?
int nitems = _total - pos;
memmove(&_items[pos+1], &_items[pos], sizeof(Fl_Tree_Item*) * nitems);
- }
+ }
_items[pos] = new_item;
_total++;
if ( _flags & MANAGE_ITEM )
{
- _items[pos]->update_prev_next(pos); // adjust item's prev/next and its neighbors
+ _items[pos]->update_prev_next(pos); // adjust item's prev/next and its neighbors
}
}
@@ -147,12 +145,12 @@ void Fl_Tree_Item_Array::add(Fl_Tree_Item *val) {
/// and the new item will take it's place, and stitched into the linked list.
///
void Fl_Tree_Item_Array::replace(int index, Fl_Tree_Item *newitem) {
- if ( _items[index] ) { // delete if non-zero
+ if ( _items[index] ) { // delete if non-zero
if ( _flags & MANAGE_ITEM )
// Destroy old item
delete _items[index];
}
- _items[index] = newitem; // install new item
+ _items[index] = newitem; // install new item
if ( _flags & MANAGE_ITEM )
{
// Restitch into linked list
@@ -165,21 +163,21 @@ void Fl_Tree_Item_Array::replace(int index, Fl_Tree_Item *newitem) {
/// The item will be delete'd (if non-NULL), so its destructor will be called.
///
void Fl_Tree_Item_Array::remove(int index) {
- if ( _items[index] ) { // delete if non-zero
+ if ( _items[index] ) { // delete if non-zero
if ( _flags & MANAGE_ITEM )
delete _items[index];
}
_items[index] = 0;
_total--;
- for ( int i=index; i<_total; i++ ) { // reshuffle the array
+ for ( int i=index; i<_total; i++ ) { // reshuffle the array
_items[i] = _items[i+1];
}
if ( _flags & MANAGE_ITEM )
{
- if ( index < _total ) { // removed item not last?
- _items[index]->update_prev_next(index); // update next item's prev/next and neighbors
- } else if ( ((index-1) >= 0) && // removed item IS last?
- ((index-1) < _total)) {
+ if ( index < _total ) { // removed item not last?
+ _items[index]->update_prev_next(index); // update next item's prev/next and neighbors
+ } else if ( ((index-1) >= 0) && // removed item IS last?
+ ((index-1) < _total)) {
_items[index-1]->update_prev_next(index-1);// update prev item's prev/next and neighbors
}
}
@@ -234,8 +232,8 @@ int Fl_Tree_Item_Array::move(int to, int from) {
// Move to new position
_items[to] = item;
// Update all children
- for ( int r=0; r<_total; r++ ) // XXX: excessive to do all children,
- _items[r]->update_prev_next(r); // XXX: but avoids weird boundary issues
+ for ( int r=0; r<_total; r++ ) // XXX: excessive to do all children,
+ _items[r]->update_prev_next(r); // XXX: but avoids weird boundary issues
return 0;
}
@@ -282,7 +280,3 @@ int Fl_Tree_Item_Array::reparent(Fl_Tree_Item *item, Fl_Tree_Item* newparent, in
_items[pos]->update_prev_next(pos); // find new siblings
return 0;
}
-
-//
-// End of "$Id$".
-//