Qore Programming Language - C/C++ Library  0.8.13
QoreValueList Class Reference

This is the list container type in Qore, dynamically allocated only, reference counted. More...

#include <QoreValueList.h>

Inheritance diagram for QoreValueList:
Collaboration diagram for QoreValueList:

Public Member Functions

DLLEXPORT QoreValueList ()
 creates an empty list
 
DLLEXPORT QoreValueList (const QoreListNode *l)
 FIXME: remove.
 
DLLEXPORT QoreValueListcopy () const
 performs a deep copy of the list and returns the new list
 
DLLEXPORT QoreValueListcopyListFrom (size_t index) const
 performs a deep copy of the list starting from element "offset" and returns the new list More...
 
DLLEXPORT bool empty () const
 returns true if the list is empty More...
 
DLLEXPORT QoreValueListevalList (ExceptionSink *xsink) const
 evaluates the list and returns a value (or 0) More...
 
DLLEXPORT QoreValueListevalList (bool &needs_deref, ExceptionSink *xsink) const
 optionally evaluates the list More...
 
DLLEXPORT QoreValueListextract (ptrdiff_t offset, ExceptionSink *xsink)
 truncates the list at position "offset" (first element is offset 0) and returns any elements removed from the list as a new list More...
 
DLLEXPORT QoreValueListextract (ptrdiff_t offset, ptrdiff_t length, ExceptionSink *xsink)
 removes "length" elements at position "offset" (first element is offset 0) and returns any elements removed from the list as a new list More...
 
DLLEXPORT QoreValueListextract (ptrdiff_t offset, ptrdiff_t length, const QoreValue l, ExceptionSink *xsink)
 adds a single value or a list of values ("l") to list possition "offset", while removing "length" elements and returns any elements removed from the list as a new list More...
 
virtual DLLEXPORT bool getAsBoolImpl () const
 returns false unless perl-boolean-evaluation is enabled, in which case it returns false only when empty More...
 
DLLEXPORT int getAsString (QoreString &str, int foff, ExceptionSink *xsink) const
 concatenate the verbose string representation of the list (including all contained values) to an existing QoreString More...
 
DLLEXPORT QoreStringgetAsString (bool &del, int foff, ExceptionSink *xsink) const
 returns a QoreString giving the verbose string representation of the List (including all contained values) More...
 
DLLEXPORT QoreValuegetEntryReference (size_t index)
 
DLLEXPORT QoreValuegetExistingEntryPtr (size_t index)
 
DLLLOCAL QoreListNodegetOldList () const
 returns a QoreListNode object corresponding to the current list More...
 
DLLLOCAL QoreListNodegetOldList (size_t start) const
 returns a QoreListNode object corresponding to the current list starting from a given offset More...
 
DLLEXPORT QoreValue getReferencedEntry (size_t index) const
 returns the element at "index" (first element is index 0), the caller owns the reference More...
 
DLLEXPORT const QoreTypeInfo * getTypeInfo () const
 returns the type info structure for the current value; also works for lists with a specific value type More...
 
virtual DLLEXPORT const char * getTypeName () const
 returns the type name as a c string
 
DLLEXPORT const QoreTypeInfo * getValueTypeInfo () const
 returns the value type declaration (if set) More...
 
virtual DLLEXPORT bool is_equal_hard (const AbstractQoreNode *v, ExceptionSink *xsink) const
 tests for equality ("deep compare" including all contained values) without type conversions (hard compare) More...
 
virtual DLLEXPORT bool is_equal_soft (const AbstractQoreNode *v, ExceptionSink *xsink) const
 tests for equality ("deep compare" including all contained values) with possible type conversion (soft compare) More...
 
DLLEXPORT QoreValueListlistRefSelf () const
 returns "this" with an incremented reference count
 
DLLEXPORT QoreValue maxValue (ExceptionSink *xsink) const
 returns the element having the highest value (determined by calling OP_LOG_GT - the greater-than ">" operator) More...
 
DLLEXPORT QoreValue maxValue (const ResolvedCallReferenceNode *fr, ExceptionSink *xsink) const
 returns the element having the highest value (determined by calling the function reference passed to give lexical order) More...
 
DLLEXPORT void merge (const QoreValueList *list)
 appends the elements of "list" to this list
 
DLLEXPORT QoreValue minValue (ExceptionSink *xsink) const
 returns the element having the lowest value (determined by calling OP_LOG_LT - the less-than "<" operator) More...
 
DLLEXPORT QoreValue minValue (const ResolvedCallReferenceNode *fr, ExceptionSink *xsink) const
 returns the element having the lowest value (determined by calling the function reference passed to give lexical order) More...
 
DLLEXPORT QoreValue pop ()
 returns the last element of the list, the length is decremented by one, caller owns the reference More...
 
virtual DLLEXPORT AbstractQoreNoderealCopy () const
 returns true if the list contains parse expressions and therefore needs evaluation to return a value, false if not More...
 
DLLEXPORT QoreValue retrieveEntry (size_t index)
 returns the element at "index" (first element is index 0) More...
 
DLLEXPORT const QoreValue retrieveEntry (size_t index) const
 returns the element at "index" (first element is index 0) More...
 
DLLEXPORT QoreValueListreverse () const
 returns a list with the order of the elements reversed
 
DLLEXPORT QoreValue shift ()
 returns the first element of the list, all other entries are moved down to fill up the first position, caller owns the reference More...
 
DLLEXPORT size_t size () const
 returns the number of elements in the list More...
 
DLLEXPORT QoreValueListsort (ExceptionSink *xsink) const
 returns a new list based on quicksorting the source list ("this") More...
 
DLLEXPORT QoreValueListsort (const ResolvedCallReferenceNode *fr, ExceptionSink *xsink) const
 returns a new list based on quicksorting the source list ("this") using the passed function reference to determine lexical order More...
 
DLLEXPORT QoreValueListsortDescending (ExceptionSink *xsink) const
 returns a new list based on quicksorting the source list ("this") in descending order More...
 
DLLEXPORT QoreValueListsortDescending (const ResolvedCallReferenceNode *fr, ExceptionSink *xsink) const
 returns a new list based on quicksorting the source list ("this") in descending order, using the passed function reference to determine lexical order More...
 
DLLEXPORT QoreValueListsortDescendingStable (ExceptionSink *xsink) const
 returns a new list based on executing mergesort on the source list ("this") in descending order More...
 
DLLEXPORT QoreValueListsortDescendingStable (const ResolvedCallReferenceNode *fr, ExceptionSink *xsink) const
 returns a new list based on executing mergesort on the source list ("this") in descending order, using the passed function reference to determine lexical order More...
 
DLLEXPORT QoreValueListsortStable (ExceptionSink *xsink) const
 returns a new list based on executing mergesort on the source list ("this") More...
 
DLLEXPORT QoreValueListsortStable (const ResolvedCallReferenceNode *fr, ExceptionSink *xsink) const
 returns a new list based on executing mergesort on the source list ("this") using the passed function reference to determine lexical order More...
 
DLLEXPORT QoreValueListsplice (ptrdiff_t offset, ExceptionSink *xsink)
 truncates the list at position "offset" (first element is offset 0) More...
 
DLLEXPORT QoreValueListsplice (ptrdiff_t offset, ptrdiff_t length, ExceptionSink *xsink)
 removes "length" elements at position "offset" (first element is offset 0) More...
 
DLLEXPORT QoreValueListsplice (ptrdiff_t offset, ptrdiff_t length, const QoreValue l, ExceptionSink *xsink)
 adds a single value or a list of values ("l") to list possition "offset", while removing "length" elements More...
 
DLLEXPORT QoreValue swap (ptrdiff_t offset, QoreValue val)
 swaps the value at the given position with the value given, caller owns any reference returned
 
DLLEXPORT QoreValue takeExists (ptrdiff_t offset)
 takes the value at the given position and replaces with NULL, only if the list position exists
 
- Public Member Functions inherited from AbstractQoreNode
DLLEXPORT AbstractQoreNode (qore_type_t t, bool n_value, bool n_needs_eval, bool n_there_can_be_only_one=false, bool n_custom_reference_handlers=false)
 constructor takes the type More...
 
DLLEXPORT AbstractQoreNode (const AbstractQoreNode &v)
 copy constructor
 
DLLEXPORT int64 bigIntEval (ExceptionSink *xsink) const
 evaluates the object and returns a 64-bit integer value More...
 
DLLEXPORT bool boolEval (ExceptionSink *xsink) const
 evaluates the object and returns a boolean value More...
 
DLLEXPORT void deref (ExceptionSink *xsink)
 decrements the reference count and calls derefImpl() if there_can_be_only_one is false, otherwise does nothing More...
 
DLLEXPORT AbstractQoreNodeeval (ExceptionSink *xsink) const
 evaluates the object and returns a value (or 0) More...
 
DLLEXPORT AbstractQoreNodeeval (bool &needs_deref, ExceptionSink *xsink) const
 optionally evaluates the argument More...
 
DLLEXPORT double floatEval (ExceptionSink *xsink) const
 evaluates the object and returns a floating-point value More...
 
DLLEXPORT int64 getAsBigInt () const
 returns the 64-bit integer value of the object More...
 
DLLEXPORT bool getAsBool () const
 returns the boolean value of the object More...
 
DLLEXPORT double getAsFloat () const
 returns the float value of the object More...
 
DLLEXPORT int getAsInt () const
 returns the integer value of the object More...
 
virtual DLLEXPORT class DateTimegetDateTimeRepresentation (bool &del) const
 returns the DateTime representation of this type (default implementation: returns ZeroDate, del = false) More...
 
virtual DLLEXPORT void getDateTimeRepresentation (DateTime &dt) const
 assigns the date representation of a value to the DateTime reference passed, default implementation does nothing More...
 
virtual DLLEXPORT QoreStringgetStringRepresentation (bool &del) const
 returns the value of the type converted to a string, default implementation: returns the empty string More...
 
virtual DLLEXPORT void getStringRepresentation (QoreString &str) const
 concatentates the value of the type to an existing QoreString reference, default implementation does nothing More...
 
DLLLOCAL qore_type_t getType () const
 returns the data type More...
 
DLLLOCAL bool hasValueApi () const
 returns the "has value api" flags - FIXME: remove with new ABI
 
DLLEXPORT int integerEval (ExceptionSink *xsink) const
 evaluates the object and returns an integer value More...
 
DLLLOCAL bool is_value () const
 returns true if the node represents a value More...
 
DLLLOCAL bool isReferenceCounted () const
 returns true if the object is reference-counted
 
DLLLOCAL bool needs_eval () const
 returns true if the object needs evaluation to return a value, false if not More...
 
virtual DLLEXPORT AbstractQoreNodeparseInit (LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo)
 for use by parse types to initialize them for execution during stage 1 parsing More...
 
DLLEXPORT void ref () const
 increments the reference count
 
DLLEXPORT AbstractQoreNoderefSelf () const
 returns "this" with an incremented reference count More...
 
- Public Member Functions inherited from QoreReferenceCounter
DLLEXPORT QoreReferenceCounter ()
 creates the reference counter object
 
DLLEXPORT QoreReferenceCounter (const QoreReferenceCounter &old)
 creates a new object with a reference count of 1 More...
 
DLLEXPORT ~QoreReferenceCounter ()
 destroys the reference counter object
 
DLLEXPORT bool is_unique () const
 returns true if the reference count is 1 More...
 
DLLEXPORT int reference_count () const
 gets the reference count More...
 
DLLEXPORT bool ROdereference () const
 atomically decrements the reference count More...
 
DLLEXPORT void ROreference () const
 atomically increments the reference count
 

Static Public Member Functions

static DLLLOCAL const char * getStaticTypeName ()
 returns true if the list does not contain any parse expressions, otherwise returns false
 

Protected Member Functions

virtual DLLEXPORT ~QoreValueList ()
 the destructor is protected so it cannot be called directly More...
 
virtual DLLLOCAL int64 bigIntEvalImpl (ExceptionSink *xsink) const
 always returns 0
 
virtual DLLLOCAL bool boolEvalImpl (ExceptionSink *xsink) const
 always returns false
 
virtual DLLEXPORT bool derefImpl (ExceptionSink *xsink)
 dereferences all elements of the list More...
 
virtual DLLEXPORT AbstractQoreNodeevalImpl (ExceptionSink *xsink) const
 evaluates the list and returns a value (or 0) More...
 
virtual DLLLOCAL AbstractQoreNodeevalImpl (bool &needs_deref, ExceptionSink *xsink) const
 optionally evaluates the argument More...
 
virtual DLLLOCAL double floatEvalImpl (ExceptionSink *xsink) const
 always returns 0.0
 
virtual DLLLOCAL int integerEvalImpl (ExceptionSink *xsink) const
 always returns 0
 
- Protected Member Functions inherited from AbstractQoreNode
virtual DLLEXPORT ~AbstractQoreNode ()
 default destructor does nothing More...
 

Protected Attributes

struct qore_value_list_private * priv
 this structure holds the private implementation for the type More...
 
- Protected Attributes inherited from AbstractQoreNode
bool custom_reference_handlers: 1
 set to one for objects that need custom reference handlers
 
bool has_value_api: 1
 set to flag with new QoreValue API (derived from ParseNode) - FIXME: to be removed when new ABI is implemented
 
bool needs_eval_flag: 1
 if this is true then the type can be evaluated
 
bool there_can_be_only_one: 1
 if this is set to true, then reference counting is turned off for objects of this class
 
qore_type_t type: 11
 the type of the object More...
 
bool value: 1
 this is true for values, if false then either the type needs evaluation to produce a value or is a parse expression
 

Detailed Description

This is the list container type in Qore, dynamically allocated only, reference counted.

it is both a value type and can hold parse expressions as well (in which case it needs to be evaluated) the first element in the list is element 0

Constructor & Destructor Documentation

◆ ~QoreValueList()

virtual DLLEXPORT QoreValueList::~QoreValueList ( )
protectedvirtual

the destructor is protected so it cannot be called directly

use the deref(ExceptionSink) function to release the reference count

See also
AbstractQoreNode::deref()
QoreValueList::derefImpl()

Member Function Documentation

◆ copyListFrom()

DLLEXPORT QoreValueList* QoreValueList::copyListFrom ( size_t  index) const

performs a deep copy of the list starting from element "offset" and returns the new list

therefore element 0 of the new list is element "offset" in the source list

Parameters
indexthe index of the element (first element is index 0)

◆ derefImpl()

virtual DLLEXPORT bool QoreValueList::derefImpl ( ExceptionSink xsink)
protectedvirtual

dereferences all elements of the list

The ExceptionSink argument is needed for those types that could throw an exception when they are deleted (ex: QoreObject) - which could be contained in the list

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
true if the object can be deleted, false if not (externally-managed)

Reimplemented from AbstractQoreNode.

◆ empty()

DLLEXPORT bool QoreValueList::empty ( ) const

returns true if the list is empty

return true if the list is empty

◆ evalImpl() [1/2]

virtual DLLEXPORT AbstractQoreNode* QoreValueList::evalImpl ( ExceptionSink xsink) const
protectedvirtual

evaluates the list and returns a value (or 0)

return value requires a deref(xsink) NOTE: if there is an exception, 0 will be returned

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here

Implements AbstractQoreNode.

◆ evalImpl() [2/2]

virtual DLLLOCAL AbstractQoreNode* QoreValueList::evalImpl ( bool &  needs_deref,
ExceptionSink xsink 
) const
protectedvirtual

optionally evaluates the argument

return value requires a deref(xsink) if needs_deref is true

See also
AbstractQoreNode::eval()

Implements AbstractQoreNode.

◆ evalList() [1/2]

DLLEXPORT QoreValueList* QoreValueList::evalList ( ExceptionSink xsink) const

evaluates the list and returns a value (or 0)

return value requires a deref(xsink) if the list does not require evaluation then "refSelf()" is used to return the same object with an incremented reference count NOTE: if the object requires evaluation and there is an exception, 0 will be returned

Parameters
xsinkif an error occurs, the Qore-language exception information will be added here

◆ evalList() [2/2]

DLLEXPORT QoreValueList* QoreValueList::evalList ( bool &  needs_deref,
ExceptionSink xsink 
) const

optionally evaluates the list

return value requires a deref(xsink) if needs_deref is true

Parameters
needs_derefthis is an output parameter, if needs_deref is true then the value returned must be dereferenced
xsinkif an error occurs, the Qore-language exception information will be added here
Note
if the list requires evaluation and there is an exception, 0 will be returned

◆ extract() [1/3]

DLLEXPORT QoreValueList* QoreValueList::extract ( ptrdiff_t  offset,
ExceptionSink xsink 
)

truncates the list at position "offset" (first element is offset 0) and returns any elements removed from the list as a new list

Parameters
offsetthe index of the element (first element is offset 0, negative offsets are offsets from the end of the list)
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
the elements removed from the list as a new list; if no elements are removed, an empty list is returned

◆ extract() [2/3]

DLLEXPORT QoreValueList* QoreValueList::extract ( ptrdiff_t  offset,
ptrdiff_t  length,
ExceptionSink xsink 
)

removes "length" elements at position "offset" (first element is offset 0) and returns any elements removed from the list as a new list

Parameters
offsetthe index of the element (first element is offset 0, negative offsets are offsets from the end of the list)
lengththe number of elements to remove (negative numbers mean all except that many elements from the end)
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
the elements removed from the list as a new list; if no elements are removed, an empty list is returned

◆ extract() [3/3]

DLLEXPORT QoreValueList* QoreValueList::extract ( ptrdiff_t  offset,
ptrdiff_t  length,
const QoreValue  l,
ExceptionSink xsink 
)

adds a single value or a list of values ("l") to list possition "offset", while removing "length" elements and returns any elements removed from the list as a new list

the "l" AbstractQoreNode (or each element if it is a QoreValueList) will be referenced for the assignment in the QoreValueList

Parameters
offsetthe index of the element (first element is offset 0, negative offsets are offsets from the end of the list)
lengththe number of elements to remove (negative numbers mean all except that many elements from the end)
lthe value or list of values to insert
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
the elements removed from the list as a new list; if no elements are removed, an empty list is returned

◆ getAsBoolImpl()

virtual DLLEXPORT bool QoreValueList::getAsBoolImpl ( ) const
virtual

returns false unless perl-boolean-evaluation is enabled, in which case it returns false only when empty

Returns
false unless perl-boolean-evaluation is enabled, in which case it returns false only when empty

Reimplemented from AbstractQoreNode.

◆ getAsString() [1/2]

DLLEXPORT int QoreValueList::getAsString ( QoreString str,
int  foff,
ExceptionSink xsink 
) const
virtual

concatenate the verbose string representation of the list (including all contained values) to an existing QoreString

used for n and N printf formatting

Parameters
strthe string representation of the type will be concatenated to this QoreString reference
fofffor multi-line formatting offset, -1 = no line breaks
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
-1 for exception raised, 0 = OK

Implements AbstractQoreNode.

◆ getAsString() [2/2]

DLLEXPORT QoreString* QoreValueList::getAsString ( bool &  del,
int  foff,
ExceptionSink xsink 
) const
virtual

returns a QoreString giving the verbose string representation of the List (including all contained values)

used for n and N printf formatting

Parameters
delif this is true when the function returns, then the returned QoreString pointer should be deleted, if false, then it must not be
fofffor multi-line formatting offset, -1 = no line breaks
xsinkif an error occurs, the Qore-language exception information will be added here NOTE: Use the QoreNodeAsStringHelper class (defined in QoreStringNode.h) instead of using this function directly
See also
QoreNodeAsStringHelper

Implements AbstractQoreNode.

◆ getEntryReference()

DLLEXPORT QoreValue& QoreValueList::getEntryReference ( size_t  index)
Parameters
indexthe index of the element (first element is index 0)

◆ getExistingEntryPtr()

DLLEXPORT QoreValue* QoreValueList::getExistingEntryPtr ( size_t  index)
Parameters
indexthe index of the element (first element is index 0)

◆ getOldList() [1/2]

DLLLOCAL QoreListNode* QoreValueList::getOldList ( ) const

returns a QoreListNode object corresponding to the current list

FIXME: remove

◆ getOldList() [2/2]

DLLLOCAL QoreListNode* QoreValueList::getOldList ( size_t  start) const

returns a QoreListNode object corresponding to the current list starting from a given offset

FIXME: remove

◆ getReferencedEntry()

DLLEXPORT QoreValue QoreValueList::getReferencedEntry ( size_t  index) const

returns the element at "index" (first element is index 0), the caller owns the reference

Parameters
indexthe index of the element (first element is index 0)
Returns
the value of the element at "index" with an incremented reference count for the caller

◆ getTypeInfo()

DLLEXPORT const QoreTypeInfo* QoreValueList::getTypeInfo ( ) const

returns the type info structure for the current value; also works for lists with a specific value type

Since
Qore 0.8.13

◆ getValueTypeInfo()

DLLEXPORT const QoreTypeInfo* QoreValueList::getValueTypeInfo ( ) const

returns the value type declaration (if set)

Since
Qore 0.8.13

◆ is_equal_hard()

virtual DLLEXPORT bool QoreValueList::is_equal_hard ( const AbstractQoreNode v,
ExceptionSink xsink 
) const
virtual

tests for equality ("deep compare" including all contained values) without type conversions (hard compare)

Parameters
vthe value to compare
xsinkif an error occurs, the Qore-language exception information will be added here

Implements AbstractQoreNode.

◆ is_equal_soft()

virtual DLLEXPORT bool QoreValueList::is_equal_soft ( const AbstractQoreNode v,
ExceptionSink xsink 
) const
virtual

tests for equality ("deep compare" including all contained values) with possible type conversion (soft compare)

Parameters
vthe value to compare
xsinkif an error occurs, the Qore-language exception information will be added here

Implements AbstractQoreNode.

◆ maxValue() [1/2]

DLLEXPORT QoreValue QoreValueList::maxValue ( ExceptionSink xsink) const

returns the element having the highest value (determined by calling OP_LOG_GT - the greater-than ">" operator)

so "soft" comparisons are made, meaning that the list can be made up of different types, and, as long as the comparisons are meaningful, the maximum value can be returned

◆ maxValue() [2/2]

DLLEXPORT QoreValue QoreValueList::maxValue ( const ResolvedCallReferenceNode fr,
ExceptionSink xsink 
) const

returns the element having the highest value (determined by calling the function reference passed to give lexical order)

Parameters
frthe function reference to be executed for each comparison to give lexical order to the elements
xsinkif an error occurs, the Qore-language exception information will be added here

◆ minValue() [1/2]

DLLEXPORT QoreValue QoreValueList::minValue ( ExceptionSink xsink) const

returns the element having the lowest value (determined by calling OP_LOG_LT - the less-than "<" operator)

so "soft" comparisons are made, meaning that the list can be made up of different types, and, as long as the comparisons are meaningful, the minimum value can be returned

◆ minValue() [2/2]

DLLEXPORT QoreValue QoreValueList::minValue ( const ResolvedCallReferenceNode fr,
ExceptionSink xsink 
) const

returns the element having the lowest value (determined by calling the function reference passed to give lexical order)

Parameters
frthe function reference to be executed for each comparison to give lexical order to the elements
xsinkif an error occurs, the Qore-language exception information will be added here

◆ pop()

DLLEXPORT QoreValue QoreValueList::pop ( )

returns the last element of the list, the length is decremented by one, caller owns the reference

if the list is empty the 0 is returned (NOTE: the last entry could also be 0 as well)

◆ realCopy()

virtual DLLEXPORT AbstractQoreNode* QoreValueList::realCopy ( ) const
virtual

returns true if the list contains parse expressions and therefore needs evaluation to return a value, false if not

performs a deep copy of the list and returns the new list

Implements AbstractQoreNode.

◆ retrieveEntry() [1/2]

DLLEXPORT QoreValue QoreValueList::retrieveEntry ( size_t  index)

returns the element at "index" (first element is index 0)

the value is not referenced for the caller

Parameters
indexthe index of the element (first element is index 0)
Returns
the value of the element at "index", not referenced for the caller

Referenced by get_hard_value_or_nothing_param(), get_hard_value_param(), and get_param_value().

◆ retrieveEntry() [2/2]

DLLEXPORT const QoreValue QoreValueList::retrieveEntry ( size_t  index) const

returns the element at "index" (first element is index 0)

the value is not referenced for the caller

Parameters
indexthe index of the element (first element is index 0)
Returns
the value of the element at "index", not referenced for the caller

◆ shift()

DLLEXPORT QoreValue QoreValueList::shift ( )

returns the first element of the list, all other entries are moved down to fill up the first position, caller owns the reference

if the list is empty the 0 is returned (NOTE: the first entry could also be 0 as well) with the current implementation the execution time for this function is O(n) where n is the length of the list

◆ size()

DLLEXPORT size_t QoreValueList::size ( ) const

returns the number of elements in the list

return the number of elements in the list

Referenced by num_args().

◆ sort() [1/2]

DLLEXPORT QoreValueList* QoreValueList::sort ( ExceptionSink xsink) const

returns a new list based on quicksorting the source list ("this")

"soft" comparisons are made using OP_LOG_LT, meaning that the list can be made up of different data types and still be sorted

◆ sort() [2/2]

DLLEXPORT QoreValueList* QoreValueList::sort ( const ResolvedCallReferenceNode fr,
ExceptionSink xsink 
) const

returns a new list based on quicksorting the source list ("this") using the passed function reference to determine lexical order

Parameters
frthe function reference to be executed for each comparison to give lexical order to the elements
xsinkif an error occurs, the Qore-language exception information will be added here

◆ sortDescending() [1/2]

DLLEXPORT QoreValueList* QoreValueList::sortDescending ( ExceptionSink xsink) const

returns a new list based on quicksorting the source list ("this") in descending order

"soft" comparisons are made using OP_LOG_LT, meaning that the list can be made up of different data types and still be sorted

◆ sortDescending() [2/2]

DLLEXPORT QoreValueList* QoreValueList::sortDescending ( const ResolvedCallReferenceNode fr,
ExceptionSink xsink 
) const

returns a new list based on quicksorting the source list ("this") in descending order, using the passed function reference to determine lexical order

Parameters
frthe function reference to be executed for each comparison to give lexical order to the elements
xsinkif an error occurs, the Qore-language exception information will be added here

◆ sortDescendingStable() [1/2]

DLLEXPORT QoreValueList* QoreValueList::sortDescendingStable ( ExceptionSink xsink) const

returns a new list based on executing mergesort on the source list ("this") in descending order

"soft" comparisons are made using OP_LOG_LT, meaning that the list can be made up of different data types and still be sorted

◆ sortDescendingStable() [2/2]

DLLEXPORT QoreValueList* QoreValueList::sortDescendingStable ( const ResolvedCallReferenceNode fr,
ExceptionSink xsink 
) const

returns a new list based on executing mergesort on the source list ("this") in descending order, using the passed function reference to determine lexical order

Parameters
frthe function reference to be executed for each comparison to give lexical order to the elements
xsinkif an error occurs, the Qore-language exception information will be added here

◆ sortStable() [1/2]

DLLEXPORT QoreValueList* QoreValueList::sortStable ( ExceptionSink xsink) const

returns a new list based on executing mergesort on the source list ("this")

"soft" comparisons are made using OP_LOG_LT, meaning that the list can be made up of different data types and still be sorted

◆ sortStable() [2/2]

DLLEXPORT QoreValueList* QoreValueList::sortStable ( const ResolvedCallReferenceNode fr,
ExceptionSink xsink 
) const

returns a new list based on executing mergesort on the source list ("this") using the passed function reference to determine lexical order

Parameters
frthe function reference to be executed for each comparison to give lexical order to the elements
xsinkif an error occurs, the Qore-language exception information will be added here

◆ splice() [1/3]

DLLEXPORT QoreValueList* QoreValueList::splice ( ptrdiff_t  offset,
ExceptionSink xsink 
)

truncates the list at position "offset" (first element is offset 0)

Parameters
offsetthe index of the element (first element is offset 0, negative offsets are offsets from the end of the list)
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
the elements removed from the list as a new list; if no elements are removed, 0 is returned

◆ splice() [2/3]

DLLEXPORT QoreValueList* QoreValueList::splice ( ptrdiff_t  offset,
ptrdiff_t  length,
ExceptionSink xsink 
)

removes "length" elements at position "offset" (first element is offset 0)

Parameters
offsetthe index of the element (first element is offset 0, negative offsets are offsets from the end of the list)
lengththe number of elements to remove (negative numbers mean all except that many elements from the end)
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
the elements removed from the list as a new list; if no elements are removed, 0 is returned

◆ splice() [3/3]

DLLEXPORT QoreValueList* QoreValueList::splice ( ptrdiff_t  offset,
ptrdiff_t  length,
const QoreValue  l,
ExceptionSink xsink 
)

adds a single value or a list of values ("l") to list possition "offset", while removing "length" elements

the "l" AbstractQoreNode (or each element if it is a QoreValueList) will be referenced for the assignment in the QoreValueList

Parameters
offsetthe index of the element (first element is offset 0, negative offsets are offsets from the end of the list)
lengththe number of elements to remove (negative numbers mean all except that many elements from the end)
lthe value or list of values to insert
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
the elements removed from the list as a new list; if no elements are removed, 0 is returned

Member Data Documentation

◆ priv

struct qore_value_list_private* QoreValueList::priv
protected

this structure holds the private implementation for the type

therefore changes to the implementation will not affect the C++ ABI


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