From: awdorrin <awdorrin@gmail.com>
Subject: Question Exception with Ada.Containers.Generic_Constrained_Array_Sort
Date: Mon, 13 Aug 2012 13:05:51 -0700 (PDT)
Date: 2012-08-13T13:05:51-07:00 [thread overview]
Message-ID: <dc3eb5cb-8919-4dff-92fd-25f6983c043b@googlegroups.com> (raw)
I had this code working, but today I started getting 'length check failed' exceptions.
I'm trying to implement a Generic_Constrained_Array_Sort to sort a slice of a constrained array.
Now I'm not sure if it is possible to pass a slice of the array into the constrained generic sort procedure.
Its possible I broke something somewhere else in the code that was related to this, but I haven't been able to track it down yet.
Here is what I'm trying to do:
procedure DXSort is new Ada.Containers.Generic_Constrained_Array_Sort(
Index_Type => Device_Index_Type,
Element_Type => Device_Object_Type,
Array_Type => Device_Array_Type,
"<" => DevName_Less_Than);
With the following declarations:
type Node_Rec_Type is private;
type Node_Ptr_Type is access Node_Rec_Type;
subtype Device_Object_Type is Node_Ptr_Type;
subtype Device_Index_Type is Int32 range 1 .. 128;
type Device_Array_Type is array(Device_Index_Type) of Device_Object_Type;
The comparison function is:
function DevName_Less_Than( L,R : Device_Object_Type) return Boolean is
begin
if GetDeviceName(L) < GetDeviceName(R)
then
return TRUE;
else
return FALSE;
end if;
end DevName_Less_Than;
I make the call to the DXSort procedure with the following call:
DXSort( DevList.DeviceList(1..DevList.Num_Devices) );
Num_Devices is always less than 128.
DevList is a record defined as:
type DevListType is record
Num_Devices : Int32;
DeviceList : Device_Array_Type;
end record;
I thought that the issue might have to do with having 'Num_Devices' of type 'Int32' in the record, but defining the 'Device_Index_Type' subtype, but experimenting with changing the type still left me with 'length check failed'.
Any suggestions would be greatly appreciated! :)
-Al
next reply other threads:[~2012-08-13 20:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-13 20:05 awdorrin [this message]
2012-08-13 20:44 ` Question Exception with Ada.Containers.Generic_Constrained_Array_Sort awdorrin
2012-08-13 21:25 ` Adam Beneschan
2012-08-14 12:22 ` awdorrin
2012-08-14 12:39 ` Marc C
2012-08-15 7:11 ` Martin
2012-08-15 16:02 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox