feisty meow concerns codebase  2.140
structures::amorph< contents > Class Template Reference

#include <amorph.h>

Inheritance diagram for structures::amorph< contents >:
Collaboration diagram for structures::amorph< contents >:

Public Member Functions

 amorph (int elements=0)
 constructs an amorph capable of holding "elements" pointers. More...
 
 ~amorph ()
 
int elements () const
 the maximum number of elements currently allowed in this amorph. More...
 
int valid_fields () const
 Returns the number of fields that have non-null contents. More...
 
void adjust (int new_max)
 Changes the maximum number of elements for this amorph. More...
 
void resize (int new_maximum=0)
 like adjust but doesn't keep existing contents. More...
 
void reset ()
 cleans out all of the contents. More...
 
basis::outcome put (int field, const contents *data)
 Enters an object into the field at index "field" in the amorph. More...
 
basis::outcome append (const contents *data)
 puts "data" on the end of this amorph. More...
 
basis::outcome operator+= (const contents *data)
 a synonym for append. More...
 
const contents * get (int field) const
 Returns a constant pointer to the information at the index "field". More...
 
contents * borrow (int field)
 Returns a pointer to the information at the index "field". More...
 
const contents * operator[] (int field) const
 synonym for get. More...
 
contents * operator[] (int field)
 synonym for borrow. More...
 
contents * acquire (int field)
 Retrieves a "field" from the amorph, taking responsibility for it back. More...
 
basis::outcome clear (int field)
 Clears the contents of the field specified. More...
 
void clear_all ()
 Clears every field in the amorph. More...
 
basis::outcome zap (int start, int end)
 Removes a range of indices from the amorph. More...
 
basis::outcome insert (int position, int lines_to_add)
 Adds "lines_to_add" indices to the amorph at the index "position". More...
 
int find_empty (basis::outcome &o) const
 Returns the index of a free field if there are any. More...
 
const contents * next_valid (int &field) const
 Returns the contents of the next valid element at or after "field". More...
 
int find (const contents *to_locate, basis::outcome &o)
 Searches the amorph for the contents specified. More...
 
void swap_contents (amorph< contents > &other)
 Exchanges the contents of "this" and "other". More...
 

Additional Inherited Members

- Protected Types inherited from basis::array< contents * >
enum  specialc_flags
 the flags specify how the array treats its contents and its length. More...
 
enum  how_to_copy
 
enum  shift_directions
 
- Protected Member Functions inherited from basis::array< contents * >
 DEFINE_CLASS_NAME ("array")
 
 array (int number=0, const contents * *init=NULL_POINTER, int flags=EXPONENTIAL_GROWTH|FLUSH_INVISIBLE)
 Constructs an array with room for "number" objects. More...
 
 array (const array< contents * > &copy_from)
 copies the contents & sizing information from "copy_from". More...
 
virtual ~array ()
 destroys the memory allocated for the objects. More...
 
void reset (int number=0, const contents * *initial_contents=NULL_POINTER)
 Resizes this array and sets the contents from an array of contents. More...
 
arrayoperator= (const array< contents * > &copy_from)
 Copies the array in "copy_from" into this. More...
 
int length () const
 Returns the current reported length of the allocated C array. More...
 
int last () const
 Returns the last valid element in the array. More...
 
int flags () const
 Provides the raw flags value, without interpreting what it means. More...
 
bool exponential () const
 Returns true if this allocator will grow exponentially on resize. More...
 
bool simple () const
 Reports whether the templated object is a simple type or not. More...
 
const contents * & get (int index) const
 Accesses individual objects stored in "this" at the "index" position. More...
 
contents * & use (int index)
 A non-constant version of get(); the returned object can be modified. More...
 
const contents * & operator[] (int index) const
 Synonym for get that provides the expected array indexing syntax. More...
 
contents * & operator[] (int index)
 Synonym for use that provides the expected array indexing syntax. More...
 
outcome put (int index, const contents * &to_put)
 Stores an object at the index "index" in the array. More...
 
array concatenation (const array &to_concatenate) const
 Returns the concatenation of "this" and the array "to_concatenate". More...
 
array concatenation (const contents * &to_concatenate) const
 Returns the concatenation of "this" and the object "to_concatenate". More...
 
arrayconcatenate (const array &to_concatenate)
 Appends the array "to_concatenate" onto "this" and returns "this". More...
 
arrayconcatenate (const contents * &to_concatenate)
 Appends the object "to_concatenate" onto "this" and returns "this". More...
 
arrayconcatenate (const contents * *to_concatenate, int length)
 Concatenates a C-array "to_concatenate" onto "this" and returns "this". More...
 
array operator+ (const array &to_cat) const
 Synonym for concatenation. More...
 
array operator+ (const contents * &to_concatenate) const
 Synonym for concatenation. More...
 
arrayoperator+= (const array &to_concatenate)
 Synonym for concatenate that modifies "this". More...
 
arrayoperator+= (const contents * &to_concatenate)
 Synonym for concatenate that modifies "this". More...
 
const contents * * observe () const
 Returns a pointer to the underlying C array of data. More...
 
contents * * access ()
 A non-constant access of the underlying C-array. BE REALLY CAREFUL. More...
 
void swap_contents (array< contents * > &other)
 Exchanges the contents of "this" and "other". More...
 
void snarf (array &new_contents)
 Drops "this" array's contents into the dustbin and uses "new_contents". More...
 
array subarray (int start, int end) const
 Returns the array segment between the indices "start" and "end". More...
 
outcome insert (int index, int new_indices)
 Adds "new_indices" new positions for objects into the array at "index". More...
 
outcome overwrite (int index, const array &write_with, int count=-1)
 Stores the array "write_with" into the current array at the "index". More...
 
outcome stuff (int length, contents * *to_stuff) const
 Copies at most "length" elements from this into the array "to_stuff". More...
 
outcome resize (int new_size, how_to_copy way=NEW_AT_END)
 Changes the size of the C array to "new_size". More...
 
outcome zap (int start, int end)
 Deletes from "this" the objects inclusively between "start" and "end". More...
 
outcome shrink ()
 Cuts loose any allocated space that is beyond the real length. More...
 
outcome retrain (int new_size, const contents * *to_copy)
 Resizes the C array and stuffs it with the contents in "to_copy". More...
 
void shift_data (shift_directions where)
 The valid portion of the array is moved to the left or right. More...
 
int internal_real_length () const
 Gritty Internal: the real allocated length. More...
 
int internal_offset () const
 Gritty Internal: the offset from real start to stored data. More...
 
const contents * * internal_block_start () const
 Gritty Internal: constant peek at the real allocated pointer. More...
 
contents * * internal_block_start ()
 Gritty Internal: the real allocated pointer made accessible. More...
 
contents * *const * internal_offset_mem () const
 Gritty Internal: the start of the actual stored data. More...
 

Detailed Description

template<class contents>
class structures::amorph< contents >

Definition at line 58 of file amorph.h.

Constructor & Destructor Documentation

◆ amorph()

template<class contents >
amorph::amorph ( int  elements = 0)

constructs an amorph capable of holding "elements" pointers.

Definition at line 247 of file amorph.h.

References CHECK_FIELDS, structures::amorph< contents >::elements(), and FUNCDEF.

◆ ~amorph()

template<class contents >
amorph::~amorph

Definition at line 258 of file amorph.h.

References CHECK_FIELDS, and FUNCDEF.

Member Function Documentation

◆ acquire()

template<class contents >
contents * amorph::acquire ( int  field)

Retrieves a "field" from the amorph, taking responsibility for it back.

This function is similar to get, except that the contents are pulled out of the amorph. The contents will no longer be destroyed when the amorph is destroyed. To store the modified contents again, use put, and then the amorph will take over management of the contents again. Note that the index is not zapped with this function; the acquired "field" will simply hold a null pointer.

Definition at line 419 of file amorph.h.

References basis::array< contents >::access(), CHECK_FIELDS, FUNCDEF, and NULL_POINTER.

◆ adjust()

template<class contents >
void amorph::adjust ( int  new_max)

Changes the maximum number of elements for this amorph.

If the new number is smaller than the original, then the fields at index "new_maximum" and upwards are thrown away. existing fields are kept.

Definition at line 321 of file amorph.h.

References CHECK_FIELDS, FUNCDEF, basis::array< contents >::insert(), NULL_POINTER, and basis::array< contents >::put().

◆ append()

template<class contents >
basis::outcome amorph::append ( const contents *  data)

puts "data" on the end of this amorph.

adds an element to the end of the amorph by increasing the amorph size (with "adjust") and putting the element into the new spot (with "put").

Definition at line 303 of file amorph.h.

References CHECK_FIELDS, and FUNCDEF.

Referenced by octopi::entity_data_bin::acquire_for_entity(), and structures::amorph_unpack().

◆ borrow()

template<class contents >
contents * amorph::borrow ( int  field)

Returns a pointer to the information at the index "field".

Also returns NULL_POINTER for invalid indexes. DO NOT destroy the returned pointer; it is still owned by the amorph.

Definition at line 448 of file amorph.h.

References basis::array< contents >::access(), bounds_return, CHECK_FIELDS, FUNCDEF, and NULL_POINTER.

Referenced by synchronic::list_manager::clean(), synchronic::list_manager::consume(), and synchronic::list_manager::update().

◆ clear()

template<class contents >
basis::outcome amorph::clear ( int  field)

Clears the contents of the field specified.

Clearing an empty field has no effect. Clearing an invalid field has no effect. NOTE: clearing the contents means that the contents are destroyed, not just disconnected.

Definition at line 411 of file amorph.h.

References CHECK_FIELDS, FUNCDEF, and NULL_POINTER.

◆ clear_all()

template<class contents >
void amorph::clear_all

Clears every field in the amorph.

Definition at line 295 of file amorph.h.

References CHECK_FIELDS, and FUNCDEF.

Referenced by structures::amorph_assign().

◆ elements()

◆ find()

template<class contents >
int amorph::find ( const contents *  to_locate,
basis::outcome o 
)

Searches the amorph for the contents specified.

Since only pointers to the contents are maintained, the search is based on finding a pointer in the amorph that is identical to "to_locate". if "o" is OKAY, then the index of the entry is returned. If "o" is NOT_FOUND, then the contents are not present.

Definition at line 432 of file amorph.h.

References CHECK_FIELDS, and FUNCDEF.

◆ find_empty()

template<class contents >
int amorph::find_empty ( basis::outcome o) const

Returns the index of a free field if there are any.

The returned index is invalid if the "o" is IS_FULL.

Definition at line 385 of file amorph.h.

References AMO_ALERT, CHECK_FIELDS, and FUNCDEF.

◆ get()

template<class contents >
const contents * amorph::get ( int  field) const

Returns a constant pointer to the information at the index "field".

If no information is stored or the field is out range, then NULL_POINTER is returned.

Definition at line 312 of file amorph.h.

References bounds_return, CHECK_FIELDS, FUNCDEF, NULL_POINTER, and basis::array< contents >::observe().

Referenced by structures::amorph_assign(), structures::amorph_pack(), structures::amorph_packed_size(), filesystem::heavy_file_operations::buffer_files(), synchronic::list_manager::clone_object(), filesystem::filename_list::operator=(), and synchronic::list_manager::retrieve().

◆ insert()

template<class contents >
basis::outcome amorph::insert ( int  position,
int  lines_to_add 
)

Adds "lines_to_add" indices to the amorph at the index "position".

If "lines_to_add" is non-positive, the request is ignored. Inserting at a position beyond the bounds of the array is ignored, but a position AT elements() is allowed (it is an append...).

Definition at line 345 of file amorph.h.

References bounds_return, CHECK_FIELDS, FUNCDEF, and basis::array< contents >::insert().

Referenced by structures::amorph_assign().

◆ next_valid()

template<class contents >
const contents * amorph::next_valid ( int &  field) const

Returns the contents of the next valid element at or after "field".

"field" is set to the location where an entry was found, if one was actually found. If none exists at "field" or after it, then NULL_POINTER is returned.

Definition at line 397 of file amorph.h.

References bounds_return, CHECK_FIELDS, FUNCDEF, basis::array< contents >::get(), and NULL_POINTER.

◆ operator+=()

template<class contents >
basis::outcome structures::amorph< contents >::operator+= ( const contents *  data)
inline

a synonym for append.

Definition at line 97 of file amorph.h.

◆ operator[]() [1/2]

template<class contents >
contents* structures::amorph< contents >::operator[] ( int  field)
inline

synonym for borrow.

Definition at line 112 of file amorph.h.

◆ operator[]() [2/2]

template<class contents >
const contents* structures::amorph< contents >::operator[] ( int  field) const
inline

synonym for get.

Definition at line 110 of file amorph.h.

◆ put()

template<class contents >
basis::outcome amorph::put ( int  field,
const contents *  data 
)

Enters an object into the field at index "field" in the amorph.

If "data" is NULL_POINTER, then the field is cleared. The amorph considers the pointer "data" to be its own property after put is invoked; "data" should not be destructed since the amorph will automatically do so. This restriction does not hold if the object is checked back out of the amorph with acquire().

Definition at line 370 of file amorph.h.

References basis::array< contents >::access(), bounds_return, CHECK_FIELDS, and FUNCDEF.

Referenced by structures::amorph_assign().

◆ reset()

◆ resize()

template<class contents >
void amorph::resize ( int  new_maximum = 0)

like adjust but doesn't keep existing contents.

Definition at line 286 of file amorph.h.

References CHECK_FIELDS, and FUNCDEF.

Referenced by structures::amorph< contents >::reset().

◆ swap_contents()

template<class contents >
void amorph::swap_contents ( amorph< contents > &  other)

Exchanges the contents of "this" and "other".

No validation is performed but this should always succeed given amorphs that are constructed properly.

Definition at line 457 of file amorph.h.

References CHECK_FIELDS, FUNCDEF, and basis::array< contents >::swap_contents().

◆ valid_fields()

template<class contents >
int structures::amorph< contents >::valid_fields ( ) const
inline

Returns the number of fields that have non-null contents.

This might be different from the number of total elements.

Definition at line 69 of file amorph.h.

◆ zap()

template<class contents >
basis::outcome amorph::zap ( int  start,
int  end 
)

Removes a range of indices from the amorph.

This does not just clear the field associated with the specified index as "clear" does, it actually changes the number of total elements by removing the indices from the amorph. The new amorph contains the old elements up to just before the "start" and from the "end" + 1 through the end of the amorph. AMORPH_BAD_INDEX is returned if either index is out of range. If the zap succeeds, then AMORPH_OKAY is returned, even if the "end" is less than the "start".

Definition at line 357 of file amorph.h.

References bounds_return, CHECK_FIELDS, FUNCDEF, and basis::array< contents >::zap().

Referenced by structures::amorph_assign(), synchronic::list_manager::clean(), synchronic::list_manager::consume(), filesystem::directory_tree::remove_path(), synchronic::list_manager::reset(), and synchronic::list_manager::zap().


The documentation for this class was generated from the following file: