Remove private class Fl_Int_Vector

This class was used in pre-C++11 versions (up to 1.4.x) and is no
longer needed.
This commit is contained in:
Albrecht Schlosser 2025-07-03 22:37:49 +02:00
parent 4e1450d750
commit d5220370b1
4 changed files with 1 additions and 254 deletions

View File

@ -1085,7 +1085,7 @@ corresponding text via function \c xkb_state_key_get_utf8() which is put in \c F
Then, a few calls to functions whose name begin with \c xkb_compose_ are necessary to support
dead and compose keys. Finally a call to \c Fl::handle() sends an \c FL_KEYDOWN or \c FL_KEYUP event to
the appropriate \c Fl_Window. Also, function \c wl_keyboard_key() uses global variable
<tt>Fl_Int_Vector key_vector</tt> to record all currently pressed keys. This is the base of the
<tt>std::vector<int> key_vector</tt> to record all currently pressed keys. This is the base of the
implementation of \c Fl_Wayland_Screen_Driver::event_key(int).
5) Function \c wl_keyboard_modifiers() runs when a modifier key (e.g., shift, control) is pressed or

View File

@ -63,7 +63,6 @@ set(CPPFILES
Fl_Input.cxx
Fl_Input_.cxx
Fl_Input_Choice.cxx
Fl_Int_Vector.cxx
Fl_Light_Button.cxx
Fl_Menu.cxx
Fl_Menu_.cxx

View File

@ -1,179 +0,0 @@
//
// An STL-ish vector without templates for the Fast Light Tool Kit (FLTK).
//
// Copyright 2002 by Greg Ercolano.
// Copyright 2022-2023 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// https://www.fltk.org/COPYING.php
//
// Please see the following page on how to report bugs and issues:
//
// https://www.fltk.org/bugs.php
//
#ifndef Fl_Int_Vector_H
#define Fl_Int_Vector_H
/**
\cond DriverDev
\addtogroup DriverDeveloper
\{
*/
#include <FL/Fl_Export.H>
/** \file src/Fl_Int_Vector.H
An STL-ish vector implemented without templates.
*/
/**
An STL-ish vector without templates.
Handles dynamic memory management of an integer array, and allows
array elements to be accessed with zero based indexing: v[0], v[1]..
Common use:
\code
#include <stdio.h>
#include "Fl_Int_Vector.H"
int main() {
Fl_Int_Vector v;
// Create an array of values 11,22,33:
v.push_back(11); // add first element
v.push_back(22); // add second element
v.push_back(33); // add third element
// Assignment by subscript
v[1] = 222; // changes 2nd element from 22 to 222
// Loop through printing the values
for ( unsigned int i=0; i<v.size(); i++ )
printf("%d ", v[i]); // access the elements
printf("\n");
// Clear the array
v.size(0);
}
\endcode
\todo
- Note: this class is only for internal use and deprecated by design.
It will be replaced with std::vector<int> in the next version after 1.4.x.
- Add other std::vector methods like erase(), etc.
- Make memory blocking size flexible, and add related methods like capacity(), reserve(), shrink_to_fit(), etc.
- Add non-std methods that are nevertheless needed, e.g. insert(index,val), delete(index), delete(start, end), swap(a_idx,b_idx)
*/
class FL_EXPORT Fl_Int_Vector {
int *arr_;
unsigned int size_;
/**
Initialize internals.
Private: For use internally by the class's ctors only.
*/
void init() {
arr_ = 0;
size_ = 0;
}
void copy(int *newarr, unsigned int newsize);
public:
/** Create an empty vector of integers. */
Fl_Int_Vector() {
init();
}
~Fl_Int_Vector();
/** Copy constructor. */
Fl_Int_Vector(Fl_Int_Vector &o) {
init();
copy(o.arr_, o.size_);
}
/**
Assignment operator. Similar to the copy constructor,
creates a separate copy of the source array, freeing any
previous contents in the current integer array.
*/
Fl_Int_Vector &operator=(Fl_Int_Vector &o) {
init();
copy(o.arr_, o.size_);
return *this;
}
/**
Access the specified integer element at index position \p x.
\warning No range checking is done on \p x, which must be less than size().
*/
int operator[](int x) const {
return arr_[x];
}
/**
Access the specified integer element at index position \p x as a reference.
This allows assignment by index through the returned reference, e.g. arr[1] = 222;
where arr[1] ends up being a reference to ptr[1], and then 222 is assigned to that ref.
\warning No range checking is done on \p x, which must be less than size().
*/
int &operator[](int x) {
return arr_[x];
}
/** Return the number of integer elements in the array. */
unsigned int size() const {
return size_;
}
void size(unsigned int count);
/**
Removes the last element the last element and returns its value.
\warning You must not call pop_back() if the array is empty, i.e. if (size() == 0).
\todo Internals should maybe assert(size_ != 0)
*/
int pop_back() {
int tmp = arr_[size_ - 1];
size_--;
return tmp;
}
/** Appends \p val to the array, enlarging the array by one. */
void push_back(int val) {
unsigned int x = size_;
size(size_ + 1);
arr_[x] = val;
}
/**
Return the last element in the array.
\warning You must not call back() if the array is empty, i.e. if (size() == 0).
\todo Internals should maybe assert(size_ != 0)
*/
int back() const {
return arr_[size_ - 1];
}
/**
Checks if array has no elements.
Same as a test for (size() == 0).
*/
bool empty() const {
return (size_ == 0) ? true : false;
}
};
/**
\}
\endcond
*/
#endif // Fl_Int_Vector_H

View File

@ -1,73 +0,0 @@
//
// An STL-ish vector without templates for the Fast Light Tool Kit (FLTK).
//
// Copyright 2002 by Greg Ercolano.
// Copyright 2022 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// https://www.fltk.org/COPYING.php
//
// Please see the following page on how to report bugs and issues:
//
// https://www.fltk.org/bugs.php
//
/**
\cond DriverDev
\addtogroup DriverDeveloper
\{
*/
#include "Fl_Int_Vector.H"
#include <stdlib.h>
#include <string.h>
/**
Make a copy of another array.
Private: For use internally by the class's copy ctors only.
*/
void Fl_Int_Vector::copy(int *newarr, unsigned int newsize) {
size(newsize);
memcpy(arr_, newarr, newsize * sizeof(int));
}
/** Destructor - frees the internal array and destroys the class. */
Fl_Int_Vector::~Fl_Int_Vector() {
if (arr_)
free(arr_);
}
/**
Set the size of the array to \p count.
Setting size to zero clears the array and frees any memory it used.
Shrinking truncates the array and frees memory of truncated elements.
Enlarging creates new elements that are zero in value.
*/
void Fl_Int_Vector::size(unsigned int count) {
if (count == 0) { // zero? special case frees memory
if (arr_)
free(arr_);
arr_ = 0;
size_ = 0;
return;
}
if (count > size_) { // array enlarged? realloc + init new vals to 0
arr_ = (int *)realloc(arr_, count * sizeof(int));
while ( size_ < count ) {
arr_[size_++] = 0;
}
return; // leaves with size_ == count
}
// count <= size_? just truncate
size_ = count;
}
/**
\}
\endcond
*/